@@ -98,6 +98,8 @@ let extract_concrete_typedecl: (Env.t ->
9898 Types. type_expr ->
9999 Path. t * Path. t * Types. type_declaration) ref = ref (Obj. magic () )
100100
101+ let expand_head: (Env. t -> Types. type_expr -> Types. type_expr) ref = ref (Obj. magic () )
102+
101103let process_tag_type (attrs : Parsetree.attributes ) =
102104 let st : tag_type option ref = ref None in
103105 Ext_list. iter attrs (fun ({txt; loc} , payload ) ->
@@ -158,34 +160,33 @@ let type_to_instanceof_backed_obj (t : Types.type_expr) =
158160 | _ -> None )
159161 | _ -> None
160162
161- let get_block_type ~env (cstr : Types.constructor_declaration ) :
162- block_type option =
163- match (process_untagged cstr.cd_attributes, cstr.cd_args) with
164- | false , _ -> None
165- | true , Cstr_tuple [{desc = Tconstr (path, _, _)}]
166- when Path. same path Predef. path_string ->
163+ let get_block_type_from_typ ~env (t : Types.type_expr ) : block_type option =
164+ let t = ! expand_head env t in
165+ match t with
166+ | {desc = Tconstr (path , _ , _ )} when Path. same path Predef. path_string ->
167167 Some StringType
168- | true , Cstr_tuple [{desc = Tconstr (path, _, _)}]
169- when Path. same path Predef. path_int ->
168+ | {desc = Tconstr (path , _ , _ )} when Path. same path Predef. path_int ->
170169 Some IntType
171- | true , Cstr_tuple [{desc = Tconstr (path, _, _)}]
172- when Path. same path Predef. path_float ->
170+ | {desc = Tconstr (path , _ , _ )} when Path. same path Predef. path_float ->
173171 Some FloatType
174- | true , Cstr_tuple [({desc = Tconstr _} as t)]
175- when Ast_uncurried_utils. typeIsUncurriedFun t ->
172+ | ({desc = Tconstr _ } as t ) when Ast_uncurried_utils. typeIsUncurriedFun t ->
176173 Some FunctionType
177- | true , Cstr_tuple [{desc = Tarrow _}] -> Some FunctionType
178- | true , Cstr_tuple [{desc = Tconstr (path, _, _)}]
179- when Path. same path Predef. path_string ->
174+ | {desc = Tarrow _ } -> Some FunctionType
175+ | {desc = Tconstr (path , _ , _ )} when Path. same path Predef. path_string ->
180176 Some StringType
181- | true , Cstr_tuple [({desc = Tconstr _} as t)] when type_is_builtin_object t
182- ->
177+ | ({desc = Tconstr _ } as t ) when type_is_builtin_object t ->
183178 Some ObjectType
184- | true , Cstr_tuple [({desc = Tconstr _} as t)] when type_to_instanceof_backed_obj t |> Option. is_some
185- ->
179+ | ({desc = Tconstr _ } as t ) when type_to_instanceof_backed_obj t |> Option. is_some ->
186180 (match type_to_instanceof_backed_obj t with
187181 | None -> None
188182 | Some instanceType -> Some (InstanceType instanceType))
183+ | _ -> None
184+
185+ let get_block_type ~env (cstr : Types.constructor_declaration ) :
186+ block_type option =
187+ match (process_untagged cstr.cd_attributes, cstr.cd_args) with
188+ | false , _ -> None
189+ | true , Cstr_tuple [{desc = Tconstr _} as t] when get_block_type_from_typ ~env t |> Option. is_some -> get_block_type_from_typ ~env t
189190 | true , Cstr_tuple [ty] -> (
190191 let default = Some UnknownType in
191192 match ! extract_concrete_typedecl env ty with
0 commit comments