Skip to content

Commit 4786605

Browse files
committed
Type instantiation when extracting object or function types.
1 parent 8515796 commit 4786605

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,9 +1057,10 @@ let rec extractObjectType ~env ~package (t : Types.type_expr) =
10571057
match t.desc with
10581058
| Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> extractObjectType ~env ~package t1
10591059
| Tobject (tObj, _) -> Some (env, tObj)
1060-
| Tconstr (path, _, _) -> (
1060+
| Tconstr (path, typeArgs, _) -> (
10611061
match References.digConstructor ~env ~package path with
1062-
| Some (env, {item = {decl = {type_manifest = Some t1}}}) ->
1062+
| Some (env, {item = {decl = {type_manifest = Some t1; type_params = typeParams}}}) ->
1063+
let t1 = t1 |> instantiateType ~typeParams ~typeArgs in
10631064
extractObjectType ~env ~package t1
10641065
| _ -> None)
10651066
| _ -> None
@@ -1069,9 +1070,10 @@ let extractFunctionType ~env ~package typ =
10691070
match t.desc with
10701071
| Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> loop ~env acc t1
10711072
| Tarrow (label, tArg, tRet, _) -> loop ~env ((label, tArg) :: acc) tRet
1072-
| Tconstr (path, _, _) -> (
1073+
| Tconstr (path, typeArgs, _) -> (
10731074
match References.digConstructor ~env ~package path with
1074-
| Some (env, {item = {decl = {type_manifest = Some t1}}}) ->
1075+
| Some (env, {item = {decl = {type_manifest = Some t1; type_params = typeParams}}}) ->
1076+
let t1 = t1 |> instantiateType ~typeParams ~typeArgs in
10751077
loop ~env acc t1
10761078
| _ -> (List.rev acc, t))
10771079
| _ -> (List.rev acc, t)

0 commit comments

Comments
 (0)