Skip to content

Commit 752dbc8

Browse files
cknittclaude
andcommitted
Register module types of an applied functor's signature
Codex review on #9084: the applied signature's module types were dropped, because the signature walk handled modules but not module types, so a member declared with one, such as `Applied.Nested.value` with `module Nested: S`, no longer resolved. Module types are registered like those of a structure now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kbf3gLMawVgtmiKy3TMBc3 Claude-Session: https://claude.ai/code/session_01Kr4cjoUi2f5VpMvE6wT9bo Signed-off-by: Christoph Knittel <ck@cca.io>
1 parent f3cf286 commit 752dbc8

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

‎analysis/src/process_cmt.ml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,28 @@ let rec for_type_signature_item ~(env : Shared_types.Env.t)
165165
loc = declared.extent_loc;
166166
};
167167
]
168+
| Sig_modtype (ident, {mtd_type = Some mod_type; mtd_attributes; mtd_loc}) ->
169+
let name = Ident.name ident in
170+
let env = env |> Env.add_module_type ~name in
171+
let declared =
172+
add_declared ~extent:mtd_loc
173+
~item:(for_type_module ~name ~env mod_type)
174+
~name:(Location.mkloc name mtd_loc)
175+
~stamp:(Ident.binding_time ident) ~env mtd_attributes
176+
(Exported.add exported Exported.Module)
177+
Stamps.add_module
178+
in
179+
[
180+
{
181+
Module.kind =
182+
Module
183+
{type_ = declared.item; is_module_type = is_module_type declared};
184+
name = declared.name.txt;
185+
docstring = declared.docstring;
186+
deprecated = declared.deprecated;
187+
loc = declared.extent_loc;
188+
};
189+
]
168190
| _ -> []
169191

170192
and for_type_signature ~name ~env signature =

‎tests/analysis_tests/tests/src/AppliedFunctor.res‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,20 @@ let shape = Shapes.Box(1)
6262

6363
let py = p.x
6464
// ^ren y
65+
66+
module WithModType = (O: Ord) => {
67+
module type S = {
68+
let value: int
69+
}
70+
module Nested: S = {
71+
let value = 1
72+
}
73+
}
74+
75+
module Applied = WithModType(IntOrd)
76+
77+
let nv = Applied.Nested.value
78+
// ^hov
79+
80+
// let nv2 = Applied.Nested.
81+
// ^com

‎tests/analysis_tests/tests/src/expected/AppliedFunctor.res.txt‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,16 @@ Rename src/AppliedFunctor.res 62:11 y
223223
}
224224
]
225225

226+
Hover src/AppliedFunctor.res 76:24
227+
{ "contents": { "kind": "markdown", "value": "```rescript\nint\n```" } }
228+
229+
Complete src/AppliedFunctor.res 79:28
230+
pos_cursor:[79:28] pos_no_white:[79:27] Found expr:[79:13->79:28]
231+
Pexp_ident Applied.Nested.:[79:13->79:28]
232+
Completable: Cpath Value[Applied, Nested, ""]
233+
Package opens Stdlib.place holder Pervasives.JsxModules.place holder
234+
Resolved opens 1 Stdlib
235+
ContextPath Value[Applied, Nested, ""]
236+
Path Applied.Nested.
237+
[ { "detail": "int", "kind": 12, "label": "value", "tags": [] } ]
238+

0 commit comments

Comments
 (0)