@@ -1533,15 +1533,14 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
15331533 // INCOMPLETENESS: Attribs is empty here, so we can't look at attributes for
15341534 // either .NET or F# parameters
15351535 let argInfo : ArgReprInfo = { Name= nmOpt; Attribs= [] }
1536- yield FSharpParameter( cenv, pty, argInfo, x.DeclarationLocationOpt, isParamArrayArg, isOutArg, optArgInfo.IsOptional) ]
1536+ yield FSharpParameter( cenv, pty, argInfo, x.DeclarationLocationOpt, isParamArrayArg, isOutArg, optArgInfo.IsOptional) ]
15371537 |> makeReadOnlyCollection ]
15381538 |> makeReadOnlyCollection
15391539
15401540 | E _ -> [] |> makeReadOnlyCollection
15411541 | M m ->
1542-
15431542 [ for argtys in m.GetParamDatas( cenv.amap, range0, m.FormalMethodInst) do
1544- yield
1543+ yield
15451544 [ for ( ParamData( isParamArrayArg, isOutArg, optArgInfo, nmOpt,_ reflArgInfo, pty)) in argtys do
15461545 // INCOMPLETENESS: Attribs is empty here, so we can't look at attributes for
15471546 // either .NET or F# parameters
@@ -1555,8 +1554,8 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
15551554 | None ->
15561555 let _ , tau = v.TypeScheme
15571556 if isFunTy cenv.g tau then
1558- let typeArguments , _typ = stripFunTy cenv.g tau
1559- [ for typ in typeArguments do
1557+ let argtysl , _typ = stripFunTy cenv.g tau
1558+ [ for typ in argtysl do
15601559 let allArguments =
15611560 if isTupleTy cenv.g typ
15621561 then tryDestTupleTy cenv.g typ
@@ -1571,7 +1570,6 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
15711570 let tau = v.TauType
15721571 let argtysl , _ = GetTopTauTypeInFSharpForm cenv.g curriedArgInfos tau range0
15731572 let argtysl = if v.IsInstanceMember then argtysl.Tail else argtysl
1574-
15751573 [ for argtys in argtysl do
15761574 yield
15771575 [ for argty, argInfo in argtys do
@@ -1594,7 +1592,6 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
15941592 // For non-standard events, just use the delegate type as the ReturnParameter type
15951593 e.GetDelegateType( cenv.amap, range0)
15961594
1597- let _ , rty , _cxs = PrettyTypes.PrettifyTypes1 cenv.g rty
15981595 FSharpParameter( cenv, rty, retInfo, x.DeclarationLocationOpt, isParamArrayArg= false , isOutArg= false , isOptionalArg= false )
15991596
16001597 | P p ->
@@ -1611,16 +1608,12 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
16111608 match v.ValReprInfo with
16121609 | None ->
16131610 let _ , tau = v.TypeScheme
1614- if isFunTy cenv.g tau then
1615- let _typeArguments , rty = stripFunTy cenv.g tau
1616- FSharpParameter( cenv, rty, { Name= None; Attribs= [] }, x.DeclarationLocationOpt, isParamArrayArg= false , isOutArg= false , isOptionalArg= false )
1617- else
1618- failwith " not a module let binding or member"
1611+ let _argtysl , rty = stripFunTy cenv.g tau
1612+ let empty : ArgReprInfo = { Name= None; Attribs= [] }
1613+ FSharpParameter( cenv, rty, empty, x.DeclarationLocationOpt, isParamArrayArg= false , isOutArg= false , isOptionalArg= false )
16191614 | Some ( ValReprInfo(_ typars, argInfos, retInfo)) ->
1620-
16211615 let tau = v.TauType
1622- let _ , rty = GetTopTauTypeInFSharpForm cenv.g argInfos tau range0
1623-
1616+ let _c , rty = GetTopTauTypeInFSharpForm cenv.g argInfos tau range0
16241617 FSharpParameter( cenv, rty, retInfo, x.DeclarationLocationOpt, isParamArrayArg= false , isOutArg= false , isOptionalArg= false )
16251618
16261619
@@ -1835,27 +1828,77 @@ and FSharpType(cenv, typ:TType) =
18351828 GetSuperTypeOfType cenv.g cenv.amap range0 typ
18361829 |> Option.map ( fun ty -> FSharpType( cenv, ty))
18371830
1838- member x.Instantiate ( tys :( FSharpGenericParameter * FSharpType ) list ) =
1839- let typI = instType ( tys |> List.map ( fun ( tyv , typ ) -> tyv.V, typ.Typ )) typ
1831+ member x.Instantiate ( instantiation :( FSharpGenericParameter * FSharpType ) list ) =
1832+ let typI = instType ( instantiation |> List.map ( fun ( tyv , typ ) -> tyv.V, typ.V )) typ
18401833 FSharpType( cenv, typI)
18411834
1842- member private x.Typ = typ
1835+ member private x.V = typ
1836+ member private x.cenv = cenv
1837+
1838+ member private typ.AdjustType ( t ) =
1839+ FSharpType( typ.cenv, t)
18431840
18441841 override x.Equals ( other : obj ) =
18451842 box x === other ||
18461843 match other with
1847- | :? FSharpType as t -> typeEquiv cenv.g typ t.Typ
1844+ | :? FSharpType as t -> typeEquiv cenv.g typ t.V
18481845 | _ -> false
18491846
18501847 override x.GetHashCode () = hash x
18511848
18521849 member x.Format ( denv : FSharpDisplayContext ) =
18531850 protect <| fun () ->
1854- NicePrint.stringOfTy ( denv.Contents cenv.g) typ
1851+ NicePrint.prettyStringOfTyHighPrec ( denv.Contents cenv.g) typ
18551852
18561853 override x.ToString () =
18571854 protect <| fun () ->
1858- " type " + NicePrint.stringOfTy ( DisplayEnv.Empty( cenv.g)) typ
1855+ " type " + NicePrint.prettyStringOfTyHighPrec ( DisplayEnv.Empty( cenv.g)) typ
1856+
1857+ static member Prettify ( typ : FSharpType ) =
1858+ let t = PrettyTypes.PrettifyTypes1 typ.cenv.g typ.V |> p23
1859+ typ.AdjustType t
1860+
1861+ static member Prettify ( typs : IList < FSharpType >) =
1862+ let xs = typs |> List.ofSeq
1863+ match xs with
1864+ | [] -> []
1865+ | h :: _ ->
1866+ let cenv = h.cenv
1867+ let prettyTyps = PrettyTypes.PrettifyTypesN cenv.g [ for t in xs -> t.V ] |> p23
1868+ ( xs, prettyTyps) ||> List.map2 ( fun p pty -> p.AdjustType( pty))
1869+ |> makeReadOnlyCollection
1870+
1871+ static member Prettify ( parameter : FSharpParameter ) =
1872+ let prettyTyp = parameter.V |> PrettyTypes.PrettifyTypes1 parameter.cenv.g |> p23
1873+ parameter.AdjustType( prettyTyp)
1874+
1875+ static member Prettify ( parameters : IList < FSharpParameter >) =
1876+ let parameters = parameters |> List.ofSeq
1877+ match parameters with
1878+ | [] -> []
1879+ | h :: _ ->
1880+ let cenv = h.cenv
1881+ let prettyTyps = parameters |> List.map ( fun p -> p.V) |> PrettyTypes.PrettifyTypesN cenv.g |> p23
1882+ ( parameters, prettyTyps) ||> List.map2 ( fun p pty -> p.AdjustType( pty))
1883+ |> makeReadOnlyCollection
1884+
1885+ static member Prettify ( parameters : IList < IList < FSharpParameter >>) =
1886+ let xs = parameters |> List.ofSeq |> List.map List.ofSeq
1887+ let hOpt = xs |> List.tryPick ( function h :: _ -> Some h | _ -> None)
1888+ match hOpt with
1889+ | None -> xs
1890+ | Some h ->
1891+ let cenv = h.cenv
1892+ let prettyTyps = xs |> List.mapSquared ( fun p -> p.V) |> PrettyTypes.PrettifyTypesNN cenv.g |> p23
1893+ ( xs, prettyTyps) ||> List.map2 ( List.map2 ( fun p pty -> p.AdjustType( pty)))
1894+ |> List.map makeReadOnlyCollection |> makeReadOnlyCollection
1895+
1896+ static member Prettify ( parameters : IList < IList < FSharpParameter >>, returnParameter : FSharpParameter ) =
1897+ let xs = parameters |> List.ofSeq |> List.map List.ofSeq
1898+ let cenv = returnParameter.cenv
1899+ let prettyTyps , prettyRetTy = xs |> List.mapSquared ( fun p -> p.V) |> ( fun tys -> PrettyTypes.PrettifyTypesNN1 cenv.g ( tys, returnParameter.V) )|> p23
1900+ let ps = ( xs, prettyTyps) ||> List.map2 ( List.map2 ( fun p pty -> p.AdjustType( pty))) |> List.map makeReadOnlyCollection |> makeReadOnlyCollection
1901+ ps, returnParameter.AdjustType( prettyRetTy)
18591902
18601903and FSharpAttribute ( cenv : cenv , attrib : AttribInfo ) =
18611904
@@ -1941,7 +1984,10 @@ and FSharpParameter(cenv, typ:TType, topArgInfo:ArgReprInfo, mOpt, isParamArrayA
19411984 let idOpt = topArgInfo.Name
19421985 let m = match mOpt with Some m -> m | None -> range0
19431986 member __.Name = match idOpt with None -> None | Some v -> Some v.idText
1944- member __.Type = FSharpType( cenv, typ)
1987+ member __.cenv : cenv = cenv
1988+ member __.AdjustType ( t ) = FSharpParameter( cenv, t, topArgInfo, mOpt, isParamArrayArg, isOutArg, isOptionalArg)
1989+ member __.Type : FSharpType = FSharpType( cenv, typ)
1990+ member __.V = typ
19451991 member __.DeclarationLocation = match idOpt with None -> m | Some v -> v.idRange
19461992 member __.Attributes =
19471993 attribs |> List.map ( fun a -> FSharpAttribute( cenv, AttribInfo.FSAttribInfo( cenv.g, a))) |> makeReadOnlyCollection
0 commit comments