Skip to content

Commit 1904ff8

Browse files
committed
move from ast iterator to traversal function for finding completables in patterns
1 parent 60f8849 commit 1904ff8

File tree

4 files changed

+220
-182
lines changed

4 files changed

+220
-182
lines changed

analysis/src/CompletionBackEnd.ml

+4-14
Original file line numberDiff line numberDiff line change
@@ -1780,7 +1780,7 @@ let rec resolveNestedPattern typ ~env ~package ~nested =
17801780
| Some {typ} -> typ |> resolveNestedPattern ~env ~package ~nested)
17811781
| PRecordBody {seenFields}, Some (Trecord {env; typeExpr}) ->
17821782
Some (typeExpr, env, Some (Completable.RecordField {seenFields}))
1783-
| PVariantPayload {constructorName}, Some (Tvariant {env; constructors})
1783+
| PVariantPayload {constructorName; itemNum}, Some (Tvariant {env; constructors})
17841784
-> (
17851785
match
17861786
constructors
@@ -1789,15 +1789,10 @@ let rec resolveNestedPattern typ ~env ~package ~nested =
17891789
with
17901790
| None -> None
17911791
| Some constructor -> (
1792-
let payloadNum, nested =
1793-
match nested with
1794-
| PTupleItem {itemNum} :: nested -> (itemNum, nested)
1795-
| _ -> (0, nested)
1796-
in
1797-
match List.nth_opt constructor.args payloadNum with
1792+
match List.nth_opt constructor.args itemNum with
17981793
| None -> None
17991794
| Some (typ, _) -> typ |> resolveNestedPattern ~env ~package ~nested))
1800-
| ( PPolyvariantPayload {constructorName},
1795+
| ( PPolyvariantPayload {constructorName; itemNum},
18011796
Some (Tpolyvariant {env; constructors}) ) -> (
18021797
match
18031798
constructors
@@ -1806,12 +1801,7 @@ let rec resolveNestedPattern typ ~env ~package ~nested =
18061801
with
18071802
| None -> None
18081803
| Some constructor -> (
1809-
let payloadNum, nested =
1810-
match nested with
1811-
| PTupleItem {itemNum} :: nested -> (itemNum, nested)
1812-
| _ -> (0, nested)
1813-
in
1814-
match List.nth_opt constructor.args payloadNum with
1804+
match List.nth_opt constructor.args itemNum with
18151805
| None -> None
18161806
| Some typ -> typ |> resolveNestedPattern ~env ~package ~nested))
18171807
| PArray, Some (Tarray (env, typ)) ->

0 commit comments

Comments
 (0)