Skip to content

Commit bfbf3c9

Browse files
committedSep 9, 2021
Refactor getCmtPath, avoid going out of sync w.r.t. whether the uri is an interface.
Fixes #300
1 parent f9bfe37 commit bfbf3c9

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed
 

‎analysis/.depend

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ src/BuildSystem.cmx : \
55
src/Cli.cmx : \
66
src/Commands.cmx
77
src/Cmt.cmx : \
8-
src/Utils.cmx \
98
src/Uri2.cmx \
109
src/SharedTypes.cmx \
1110
src/ProcessCmt.cmx \

‎analysis/src/Cmt.ml

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ let fromUri ~uri =
1010
in
1111
match Hashtbl.find_opt package.pathsForModule moduleName with
1212
| Some paths ->
13-
let cmt =
14-
SharedTypes.getCmtPath ~interface:(Utils.endsWith path "i") paths
15-
in
13+
let cmt = SharedTypes.getCmtPath ~uri paths in
1614
ProcessCmt.fullForCmt ~moduleName ~package ~uri cmt
1715
| None ->
1816
prerr_endline ("can't find module " ^ moduleName);

‎analysis/src/ProcessCmt.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1260,8 +1260,8 @@ let fileForModule modname ~package =
12601260
if Hashtbl.mem package.pathsForModule modname then (
12611261
let paths = Hashtbl.find package.pathsForModule modname in
12621262
(* TODO: do better *)
1263-
let cmt = SharedTypes.getCmtPath ~interface:true paths in
12641263
let uri = SharedTypes.getUri paths in
1264+
let cmt = SharedTypes.getCmtPath ~uri paths in
12651265
Log.log ("fileForModule " ^ SharedTypes.showPaths paths);
12661266
match fileForCmt ~moduleName:modname ~cmt ~uri state with
12671267
| None -> None

‎analysis/src/SharedTypes.ml

+4-2
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,13 @@ let getUri p =
146146
| Namespace {cmt} -> Uri2.fromPath cmt
147147
| IntfAndImpl {resi} -> Uri2.fromPath resi
148148

149-
let getCmtPath ~interface p =
149+
let getCmtPath ~uri p =
150150
match p with
151151
| Impl {cmt} -> cmt
152152
| Namespace {cmt} -> cmt
153-
| IntfAndImpl {cmti; cmt} -> if interface then cmti else cmt
153+
| IntfAndImpl {cmti; cmt} ->
154+
let interface = Utils.endsWith (Uri2.toPath uri) "i" in
155+
if interface then cmti else cmt
154156

155157
let emptyDeclared name =
156158
{

0 commit comments

Comments
 (0)