Skip to content

Commit b5f6d48

Browse files
committed
Handle type instantiation for named argument completion.
1 parent 4786605 commit b5f6d48

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,10 @@ let rec extractObjectType ~env ~package (t : Types.type_expr) =
10591059
| Tobject (tObj, _) -> Some (env, tObj)
10601060
| Tconstr (path, typeArgs, _) -> (
10611061
match References.digConstructor ~env ~package path with
1062-
| Some (env, {item = {decl = {type_manifest = Some t1; type_params = typeParams}}}) ->
1062+
| Some
1063+
( env,
1064+
{item = {decl = {type_manifest = Some t1; type_params = typeParams}}}
1065+
) ->
10631066
let t1 = t1 |> instantiateType ~typeParams ~typeArgs in
10641067
extractObjectType ~env ~package t1
10651068
| _ -> None)
@@ -1072,7 +1075,11 @@ let extractFunctionType ~env ~package typ =
10721075
| Tarrow (label, tArg, tRet, _) -> loop ~env ((label, tArg) :: acc) tRet
10731076
| Tconstr (path, typeArgs, _) -> (
10741077
match References.digConstructor ~env ~package path with
1075-
| Some (env, {item = {decl = {type_manifest = Some t1; type_params = typeParams}}}) ->
1078+
| Some
1079+
( env,
1080+
{
1081+
item = {decl = {type_manifest = Some t1; type_params = typeParams}};
1082+
} ) ->
10761083
let t1 = t1 |> instantiateType ~typeParams ~typeArgs in
10771084
loop ~env acc t1
10781085
| _ -> (List.rev acc, t))
@@ -1731,9 +1738,18 @@ Note: The `@react.component` decorator requires the react-jsx config to be set i
17311738
| Tarrow ((Labelled l | Optional l), tArg, tRet, _) ->
17321739
(l, tArg) :: getLabels ~env tRet
17331740
| Tarrow (Nolabel, _, tRet, _) -> getLabels ~env tRet
1734-
| Tconstr (path, _, _) -> (
1741+
| Tconstr (path, typeArgs, _) -> (
17351742
match References.digConstructor ~env ~package path with
1736-
| Some (env, {item = {decl = {type_manifest = Some t1}}}) ->
1743+
| Some
1744+
( env,
1745+
{
1746+
item =
1747+
{
1748+
decl =
1749+
{type_manifest = Some t1; type_params = typeParams};
1750+
};
1751+
} ) ->
1752+
let t1 = t1 |> instantiateType ~typeParams ~typeArgs in
17371753
getLabels ~env t1
17381754
| _ -> [])
17391755
| _ -> []

0 commit comments

Comments
 (0)