Skip to content

Commit f782f32

Browse files
committed
Don't let exported override included
1 parent 9f66dd2 commit f782f32

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -458,21 +458,6 @@ let processLocalInclude includePath _loc ~prefix ~exact ~(env : QueryEnv.t)
458458
|> Hashtbl.iter (fun (name, _) (declared : Types.type_expr Declared.t) ->
459459
(* We check all the values if their origin is the same as the include path. *)
460460
match declared.modulePath with
461-
| ModulePath.ExportedModule {name = exportedName}
462-
when exportedName = includePath ->
463-
if Utils.checkName name ~prefix ~exact then
464-
if not (Hashtbl.mem localTables.namesUsed name) then (
465-
Hashtbl.add localTables.namesUsed name ();
466-
localTables.resultRev <-
467-
{
468-
(Completion.create declared.name.txt ~env
469-
~kind:(Value declared.item))
470-
with
471-
deprecated = declared.deprecated;
472-
docstring = declared.docstring;
473-
synthetic = true;
474-
}
475-
:: localTables.resultRev)
476461
| ModulePath.IncludedModule (source, _) ->
477462
let source_module_path =
478463
match Path.flatten source with

analysis/src/LocalTables.ml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,25 @@ let create () =
2525
let populateValues ~env localTables =
2626
env.QueryEnv.file.stamps
2727
|> Stamps.iterValues (fun _ declared ->
28-
Hashtbl.replace localTables.valueTable
29-
(declared.name.txt, declared.name.loc |> Loc.start)
30-
declared)
28+
match declared.modulePath with
29+
| ModulePath.ExportedModule _ -> (
30+
match
31+
Hashtbl.find_opt localTables.valueTable
32+
(declared.name.txt, declared.name.loc |> Loc.start)
33+
with
34+
| Some
35+
{modulePath = ModulePath.IncludedModule _; name = existingName}
36+
when declared.name.txt = existingName.txt ->
37+
(* Don't override an included module declared item with an Exported one *)
38+
()
39+
| _ ->
40+
Hashtbl.replace localTables.valueTable
41+
(declared.name.txt, declared.name.loc |> Loc.start)
42+
declared)
43+
| _ ->
44+
Hashtbl.replace localTables.valueTable
45+
(declared.name.txt, declared.name.loc |> Loc.start)
46+
declared)
3147

3248
let populateConstructors ~env localTables =
3349
env.QueryEnv.file.stamps

0 commit comments

Comments
 (0)