Skip to content

Commit 9b5673b

Browse files
committed
take uncurried into consideration when looking up functions
1 parent e84422c commit 9b5673b

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

analysis/src/TypeUtils.ml

+3-1
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ let rec extractObjectType ~env ~package (t : Types.type_expr) =
8888
| _ -> None)
8989
| _ -> None
9090

91-
let extractFunctionType ~env ~package typ =
91+
let rec extractFunctionType ~env ~package typ =
9292
let rec loop ~env acc (t : Types.type_expr) =
9393
match t.desc with
9494
| Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> loop ~env acc t1
9595
| Tarrow (label, tArg, tRet, _) -> loop ~env ((label, tArg) :: acc) tRet
96+
| Tconstr (Pident {name = "function$"}, [t; _], _) ->
97+
extractFunctionType ~env ~package t
9698
| Tconstr (path, typeArgs, _) -> (
9799
match References.digConstructor ~env ~package path with
98100
| Some

analysis/tests/src/Completion.res

+2-2
Original file line numberDiff line numberDiff line change
@@ -453,5 +453,5 @@ type someVariantWithDeprecated =
453453

454454
let uncurried = (. num) => num + 2
455455

456-
// let _ = uncurried(. 1)->
457-
// ^com
456+
// let _ = uncurried(. 1)->toS
457+
// ^com

analysis/tests/src/expected/Completion.res.txt

+13-5
Original file line numberDiff line numberDiff line change
@@ -2161,15 +2161,23 @@ Path someVariantWithDeprecated
21612161
"insertTextFormat": 2
21622162
}]
21632163

2164-
Complete src/Completion.res 455:27
2165-
posCursor:[455:27] posNoWhite:[455:26] Found expr:[455:11->0:-1]
2166-
Completable: Cpath Value[uncurried](Nolabel)->
2164+
Complete src/Completion.res 455:30
2165+
posCursor:[455:30] posNoWhite:[455:29] Found expr:[455:11->455:30]
2166+
Completable: Cpath Value[uncurried](Nolabel)->toS
21672167
Raw opens: 2 Shadow.B.place holder ... Shadow.A.place holder
21682168
Package opens Pervasives.JsxModules.place holder
21692169
Resolved opens 3 Completion.res Completion.res pervasives
2170-
ContextPath Value[uncurried](Nolabel)->
2170+
ContextPath Value[uncurried](Nolabel)->toS
21712171
ContextPath Value[uncurried](Nolabel)
21722172
ContextPath Value[uncurried]
21732173
Path uncurried
2174-
[]
2174+
CPPipe env:Completion
2175+
Path Belt.Int.toS
2176+
[{
2177+
"label": "Belt.Int.toString",
2178+
"kind": 12,
2179+
"tags": [],
2180+
"detail": "int => string",
2181+
"documentation": {"kind": "markdown", "value": "\n Converts a given `int` to a `string`. Uses the JavaScript `String` constructor under the hood.\n\n ```res example\n Js.log(Belt.Int.toString(1) === \"1\") /* true */\n ```\n"}
2182+
}]
21752183

0 commit comments

Comments
 (0)