Skip to content

Commit fdf07c7

Browse files
committed
refactor: read the .cmt earlier
1 parent 25169a5 commit fdf07c7

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

compiler/gentype/GenTypeMain.ml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,25 +142,25 @@ let process_cmt_file cmt =
142142
let output_file_relative = cmt |> Paths.get_output_file_relative ~config in
143143
let file_name = cmt |> Paths.get_module_name in
144144
let is_interface = Filename.check_suffix cmt_file ".cmti" in
145+
let input_cmt, has_gentype_annotations =
146+
read_input_cmt is_interface cmt_file
147+
in
148+
let source_file =
149+
match input_cmt.cmt_annots |> FindSourceFile.cmt with
150+
| Some source_file -> source_file
151+
| None -> (
152+
(file_name |> ModuleName.to_string)
153+
^
154+
match is_interface with
155+
| true -> ".resi"
156+
| false -> ".res")
157+
in
145158
let resolver =
146159
ModuleResolver.create_lazy_resolver ~config
147160
~extensions:[".res"; ".shim.ts"] ~exclude_file:(fun fname ->
148161
fname = "React.res" || fname = "ReasonReact.res")
149162
in
150-
let input_cmt, has_gentype_annotations =
151-
read_input_cmt is_interface cmt_file
152-
in
153163
if has_gentype_annotations then
154-
let source_file =
155-
match input_cmt.cmt_annots |> FindSourceFile.cmt with
156-
| Some source_file -> source_file
157-
| None -> (
158-
(file_name |> ModuleName.to_string)
159-
^
160-
match is_interface with
161-
| true -> ".resi"
162-
| false -> ".res")
163-
in
164164
input_cmt
165165
|> translate_c_m_t ~config ~output_file_relative ~resolver
166166
|> emit_translation ~config ~file_name ~output_file ~output_file_relative

0 commit comments

Comments
 (0)