@@ -185,6 +185,7 @@ let declaredForExportedTip ~(stamps : stamps) ~(exported : exported) name tip =
185185 Hashtbl. find_opt exported.modules name |?> fun stamp ->
186186 Hashtbl. find_opt stamps.modules stamp |?>> fun x -> {x with item = () }
187187
188+ (* * Find alternative declaration: from res in case of interface, or from resi in case of implementation *)
188189let alternateDeclared ~(file : File.t ) ~package declared tip =
189190 match Hashtbl. find_opt package.pathsForModule file.moduleName with
190191 | None -> None
@@ -193,28 +194,16 @@ let alternateDeclared ~(file : File.t) ~package declared tip =
193194 match paths with
194195 | IntfAndImpl {resi; res} -> (
195196 maybeLog " Have both!!" ;
196- let resiUri = Uri2. fromPath resi in
197- let resUri = Uri2. fromPath res in
198- if Uri2. isInterface file.uri then
199- match Cmt. fromUri ~uri: resUri with
200- | None -> None
201- | Some {file; extra} -> (
202- match
203- declaredForExportedTip ~stamps: file.stamps
204- ~exported: file.contents.exported declared.name.txt tip
205- with
206- | None -> None
207- | Some declared -> Some (file, extra, declared))
208- else
209- match Cmt. fromUri ~uri: resiUri with
197+ let alternateUri = if Uri2. isInterface file.uri then res else resi in
198+ match Cmt. fromUri ~uri: (Uri2. fromPath alternateUri) with
199+ | None -> None
200+ | Some {file; extra} -> (
201+ match
202+ declaredForExportedTip ~stamps: file.stamps
203+ ~exported: file.contents.exported declared.name.txt tip
204+ with
210205 | None -> None
211- | Some {file; extra} -> (
212- match
213- declaredForExportedTip ~stamps: file.stamps
214- ~exported: file.contents.exported declared.name.txt tip
215- with
216- | None -> None
217- | Some declared -> Some (file, extra, declared)))
206+ | Some declared -> Some (file, extra, declared)))
218207 | _ -> None )
219208
220209let rec resolveModuleReference ?(pathsSeen = [] ) ~file ~package
0 commit comments