Skip to content

Commit 3408b27

Browse files
cknittclaude
andcommitted
Qualify extension constructors of namespaced modules by source path
Codex review on #9085: the module name of another file comes from its compiled name, which in a namespaced project is `Base-MyNamespace`, so completion inserted `Base-MyNamespace.Flag`. The name is turned into its source path `MyNamespace.Base` first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kbf3gLMawVgtmiKy3TMBc3 Signed-off-by: Christoph Knittel <ck@cca.io>
1 parent 56cff12 commit 3408b27

5 files changed

Lines changed: 33 additions & 1 deletion

File tree

‎analysis/src/type_utils.ml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ let extension_constructors ~state ~package ~(current_file : File.t)
449449
in
450450
let path =
451451
if file.uri = current_file.uri then relative path scope_path
452-
else file.module_name :: path
452+
else Utils.flatten_any_namespace_in_path (file.module_name :: path)
453453
in
454454
{
455455
declared.item with
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
type attr = ..
2+
type attr += Flag | Size(int)
3+
4+
let value: attr = Flag
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let imported = ExtensibleBase.value
2+
3+
// switch importe
4+
// ^com

‎tests/analysis_tests/tests-namespaced-references/src/expected/ExtensibleBase.res.txt‎

Whitespace-only changes.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Complete src/ExtensibleUse.res 2:17
2+
XXX Not found!
3+
Completable: CexhaustiveSwitch Value[importe]
4+
Package opens Stdlib.place holder Pervasives.JsxModules.place holder MyNamespace.place holder
5+
Resolved opens 2 MyNamespace Stdlib
6+
ContextPath Value[importe]
7+
Path importe
8+
[
9+
{
10+
"detail": "MyNamespace.ExtensibleBase.attr",
11+
"kind": 12,
12+
"label": "imported",
13+
"tags": []
14+
},
15+
{
16+
"detail": "insert exhaustive switch for value",
17+
"filterText": "imported",
18+
"insertText": "imported {\n | MyNamespace.ExtensibleBase.Flag => ${1:%todo}\n | MyNamespace.ExtensibleBase.Size(_) => ${2:%todo}\n | _ => ${3:%todo}\n }",
19+
"insertTextFormat": 2,
20+
"kind": 15,
21+
"label": "imported (exhaustive switch)",
22+
"tags": []
23+
}
24+
]

0 commit comments

Comments
 (0)