@@ -243,6 +243,7 @@ let maybeSetTypeArgCtx ?typeArgContextFromTypeManifest ~typeParams ~typeArgs env
243
243
(debugLogTypeArgContext typeArgContext));
244
244
typeArgContext
245
245
246
+ (* TODO(env-stuff) Maybe this could be removed entirely if we can guarantee that we don't have to look up functions from in here. *)
246
247
let rec extractFunctionType2 ?typeArgContext ~env ~package typ =
247
248
let rec loop ?typeArgContext ~env acc (t : Types.type_expr ) =
248
249
match t.desc with
@@ -608,119 +609,9 @@ let extractTypeFromResolvedType (typ : Type.t) ~env ~full =
608
609
(* * The context we just came from as we resolve the nested structure. *)
609
610
type ctx = Rfield of string (* * A record field of name *)
610
611
611
- (* * This moves through a nested path via a set of instructions, trying to resolve the type at the end of the path. *)
612
- let rec resolveNested ~env ~full ~nested ?ctx (typ : completionType ) =
613
- match nested with
614
- | [] ->
615
- Some
616
- ( typ,
617
- env,
618
- match ctx with
619
- | None -> None
620
- | Some (Rfield fieldName ) ->
621
- Some (Completable. CameFromRecordField fieldName) )
622
- | patternPath :: nested -> (
623
- match (patternPath, typ) with
624
- | Completable. NTupleItem {itemNum} , Tuple (env , tupleItems , _ ) -> (
625
- match List. nth_opt tupleItems itemNum with
626
- | None -> None
627
- | Some typ ->
628
- typ
629
- |> extractType ~env ~package: full.package
630
- |> Utils.Option. flatMap (fun typ ->
631
- typ |> resolveNested ~env ~full ~nested ))
632
- | ( NFollowRecordField {fieldName},
633
- (TinlineRecord {env; fields} | Trecord {env; fields} ) ) -> (
634
- match
635
- fields
636
- |> List. find_opt (fun (field : field ) -> field.fname.txt = fieldName)
637
- with
638
- | None -> None
639
- | Some {typ; optional} ->
640
- let typ = if optional then Utils. unwrapIfOption typ else typ in
641
-
642
- typ
643
- |> extractType ~env ~package: full.package
644
- |> Utils.Option. flatMap (fun typ ->
645
- typ |> resolveNested ~ctx: (Rfield fieldName) ~env ~full ~nested ))
646
- | NRecordBody {seenFields}, Trecord {env; definition = `TypeExpr typeExpr}
647
- ->
648
- typeExpr
649
- |> extractType ~env ~package: full.package
650
- |> Option. map (fun typ ->
651
- (typ, env, Some (Completable. RecordField {seenFields})))
652
- | ( NRecordBody {seenFields},
653
- (Trecord {env; definition = `NameOnly _} as extractedType) ) ->
654
- Some (extractedType, env, Some (Completable. RecordField {seenFields}))
655
- | NRecordBody {seenFields} , TinlineRecord {env; fields} ->
656
- Some
657
- ( TinlineRecord {fields; env},
658
- env,
659
- Some (Completable. RecordField {seenFields}) )
660
- | ( NVariantPayload {constructorName = " Some" ; itemNum = 0 },
661
- Toption (env, ExtractedType typ) ) ->
662
- typ |> resolveNested ~env ~full ~nested
663
- | ( NVariantPayload {constructorName = " Some" ; itemNum = 0 },
664
- Toption (env, TypeExpr typ) ) ->
665
- typ
666
- |> extractType ~env ~package: full.package
667
- |> Utils.Option. flatMap (fun t -> t |> resolveNested ~env ~full ~nested )
668
- | NVariantPayload {constructorName = "Ok" ; itemNum = 0 } , Tresult {okType} ->
669
- okType
670
- |> extractType ~env ~package: full.package
671
- |> Utils.Option. flatMap (fun t -> t |> resolveNested ~env ~full ~nested )
672
- | ( NVariantPayload {constructorName = " Error" ; itemNum = 0 },
673
- Tresult {errorType} ) ->
674
- errorType
675
- |> extractType ~env ~package: full.package
676
- |> Utils.Option. flatMap (fun t -> t |> resolveNested ~env ~full ~nested )
677
- | NVariantPayload {constructorName; itemNum}, Tvariant {env; constructors}
678
- -> (
679
- match
680
- constructors
681
- |> List. find_opt (fun (c : Constructor.t ) ->
682
- c.cname.txt = constructorName)
683
- with
684
- | Some {args = Args args } -> (
685
- match List. nth_opt args itemNum with
686
- | None -> None
687
- | Some (typ , _ ) ->
688
- typ
689
- |> extractType ~env ~package: full.package
690
- |> Utils.Option. flatMap (fun typ ->
691
- typ |> resolveNested ~env ~full ~nested ))
692
- | Some {args = InlineRecord fields } when itemNum = 0 ->
693
- TinlineRecord {env; fields} |> resolveNested ~env ~full ~nested
694
- | _ -> None )
695
- | ( NPolyvariantPayload {constructorName; itemNum},
696
- Tpolyvariant {env; constructors} ) -> (
697
- match
698
- constructors
699
- |> List. find_opt (fun (c : polyVariantConstructor ) ->
700
- c.name = constructorName)
701
- with
702
- | None -> None
703
- | Some constructor -> (
704
- match List. nth_opt constructor.args itemNum with
705
- | None -> None
706
- | Some typ ->
707
- typ
708
- |> extractType ~env ~package: full.package
709
- |> Utils.Option. flatMap (fun typ ->
710
- typ |> resolveNested ~env ~full ~nested )))
711
- | NArray , Tarray (env , ExtractedType typ ) ->
712
- typ |> resolveNested ~env ~full ~nested
713
- | NArray , Tarray (env , TypeExpr typ ) ->
714
- typ
715
- |> extractType ~env ~package: full.package
716
- |> Utils.Option. flatMap (fun typ ->
717
- typ |> resolveNested ~env ~full ~nested )
718
- | _ -> None )
719
-
720
- let rec resolveNested2 ?typeArgContext ~env ~full ~nested ?ctx
612
+ let rec resolveNested ?typeArgContext ~env ~full ~nested ?ctx
721
613
(typ : completionType ) =
722
614
let extractType = extractType2 ?typeArgContext in
723
- let resolveNested = resolveNested2 in
724
615
if Debug. verbose () then
725
616
Printf. printf
726
617
" [nested]--> running nested in env: %s. Has type arg ctx: %b\n "
0 commit comments