@@ -90,6 +90,47 @@ let readCmt cmtFile =
90
90
Log_. item " Try to clean and rebuild.\n\n " ;
91
91
assert false
92
92
93
+ let readInputCmt isInterface cmtFile =
94
+ let inputCMT = readCmt cmtFile in
95
+ let ignoreInterface = ref false in
96
+ let checkAnnotation ~loc :_ attributes =
97
+ if
98
+ attributes
99
+ |> Annotation. getAttributePayload Annotation. tagIsGenTypeIgnoreInterface
100
+ <> None
101
+ then ignoreInterface := true ;
102
+ attributes
103
+ |> Annotation. getAttributePayload Annotation. tagIsOneOfTheGenTypeAnnotations
104
+ <> None
105
+ in
106
+ let hasGenTypeAnnotations =
107
+ inputCMT |> cmtCheckAnnotations ~check Annotation
108
+ in
109
+ if isInterface then
110
+ let cmtFileImpl =
111
+ (cmtFile |> (Filename. chop_extension [@ doesNotRaise])) ^ " .cmt"
112
+ in
113
+ let inputCMTImpl = readCmt cmtFileImpl in
114
+ let hasGenTypeAnnotationsImpl =
115
+ inputCMTImpl
116
+ |> cmtCheckAnnotations ~check Annotation:(fun ~loc attributes ->
117
+ if attributes |> checkAnnotation ~loc then (
118
+ if not ! ignoreInterface then (
119
+ Log_.Color. setup () ;
120
+ Log_. info ~loc ~name: " Warning genType" (fun ppf () ->
121
+ Format. fprintf ppf
122
+ " Annotation is ignored as there's a .rei file" ));
123
+ true )
124
+ else false )
125
+ in
126
+ ( (match ! ignoreInterface with
127
+ | true -> inputCMTImpl
128
+ | false -> inputCMT),
129
+ match ! ignoreInterface with
130
+ | true -> hasGenTypeAnnotationsImpl
131
+ | false -> hasGenTypeAnnotations )
132
+ else (inputCMT, hasGenTypeAnnotations)
133
+
93
134
let processCmtFile cmt =
94
135
let config = Paths. readConfig ~namespace: (cmt |> Paths. findNameSpace) in
95
136
if ! Debug. basic then Log_. item " Cmt %s\n " cmt;
@@ -104,49 +145,7 @@ let processCmtFile cmt =
104
145
~exclude File:(fun fname ->
105
146
fname = " React.res" || fname = " ReasonReact.res" )
106
147
in
107
- let inputCMT, hasGenTypeAnnotations =
108
- let inputCMT = readCmt cmtFile in
109
- let ignoreInterface = ref false in
110
- let checkAnnotation ~loc :_ attributes =
111
- if
112
- attributes
113
- |> Annotation. getAttributePayload
114
- Annotation. tagIsGenTypeIgnoreInterface
115
- <> None
116
- then ignoreInterface := true ;
117
- attributes
118
- |> Annotation. getAttributePayload
119
- Annotation. tagIsOneOfTheGenTypeAnnotations
120
- <> None
121
- in
122
- let hasGenTypeAnnotations =
123
- inputCMT |> cmtCheckAnnotations ~check Annotation
124
- in
125
- if isInterface then
126
- let cmtFileImpl =
127
- (cmtFile |> (Filename. chop_extension [@ doesNotRaise])) ^ " .cmt"
128
- in
129
- let inputCMTImpl = readCmt cmtFileImpl in
130
- let hasGenTypeAnnotationsImpl =
131
- inputCMTImpl
132
- |> cmtCheckAnnotations ~check Annotation:(fun ~loc attributes ->
133
- if attributes |> checkAnnotation ~loc then (
134
- if not ! ignoreInterface then (
135
- Log_.Color. setup () ;
136
- Log_. info ~loc ~name: " Warning genType" (fun ppf () ->
137
- Format. fprintf ppf
138
- " Annotation is ignored as there's a .rei file" ));
139
- true )
140
- else false )
141
- in
142
- ( (match ! ignoreInterface with
143
- | true -> inputCMTImpl
144
- | false -> inputCMT),
145
- match ! ignoreInterface with
146
- | true -> hasGenTypeAnnotationsImpl
147
- | false -> hasGenTypeAnnotations )
148
- else (inputCMT, hasGenTypeAnnotations)
149
- in
148
+ let inputCMT, hasGenTypeAnnotations = readInputCmt isInterface cmtFile in
150
149
if hasGenTypeAnnotations then
151
150
let sourceFile =
152
151
match inputCMT.cmt_annots |> FindSourceFile. cmt with
0 commit comments