Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions src/fsharp/vs/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,8 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
let rty = m.GetFSharpReturnTy(cenv.amap,range0,m.FormalMethodInst)
let argtysl = m.GetParamTypes(cenv.amap,range0,m.FormalMethodInst)
mkIteratedFunTy (List.map (mkTupledTy cenv.g) argtysl) rty
| V v -> v.TauType
| V v -> let _, typ, _ = PrettyTypes.PrettifyTypes1 cenv.g v.TauType
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The need to prettify types can arise not only for functions and values but also for members, properties and events. You should probably do those here too

typ
FSharpType(cenv, ty)

member __.HasGetterMethod =
Expand Down Expand Up @@ -1421,17 +1422,25 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
[ [ for (ParamData(isParamArrayArg,isOutArg,optArgInfo,nmOpt,_reflArgInfo,pty)) in p.GetParamDatas(cenv.amap,range0) do
// INCOMPLETENESS: Attribs is empty here, so we can't look at attributes for
// either .NET or F# parameters
let _, prettyTyp, _cxs = PrettyTypes.PrettifyTypes1 cenv.g pty
let argInfo : ArgReprInfo = { Name=nmOpt; Attribs= [] }
yield FSharpParameter(cenv, pty, argInfo, x.DeclarationLocationOpt, isParamArrayArg, isOutArg, optArgInfo.IsOptional) ]
yield FSharpParameter(cenv,prettyTyp , argInfo, x.DeclarationLocationOpt, isParamArrayArg, isOutArg, optArgInfo.IsOptional) ]
|> makeReadOnlyCollection ]
|> makeReadOnlyCollection

| E _ -> [] |> makeReadOnlyCollection
| M m ->

[ for argtys in m.GetParamDatas(cenv.amap,range0,m.FormalMethodInst) do
yield
[ for (ParamData(isParamArrayArg,isOutArg,optArgInfo,nmOpt,_reflArgInfo,pty)) in argtys do
let _, prettyTyps, _cxs =
argtys
|> List.map (function ParamData(isParamArrayArg,isOutArg,optArgInfo,nmOpt,_reflArgInfo,pty) -> pty)
|> PrettyTypes.PrettifyTypesN cenv.g
let combined =
List.map2 (fun pty (ParamData(isParamArrayArg,isOutArg,optArgInfo,nmOpt,reflArgInfo,_pty)) ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use (prettyTypes, argtys) ||> List.map2 (fun ... -> ...)

isParamArrayArg,isOutArg,optArgInfo,nmOpt,reflArgInfo,pty) prettyTyps argtys
yield
[ for (isParamArrayArg,isOutArg,optArgInfo,nmOpt,_reflArgInfo,pty) in combined do
// INCOMPLETENESS: Attribs is empty here, so we can't look at attributes for
// either .NET or F# parameters
let argInfo : ArgReprInfo = { Name=nmOpt; Attribs= [] }
Expand All @@ -1450,8 +1459,9 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
if isTupleTy cenv.g typ
then tryDestTupleTy cenv.g typ
else [typ]
let _, prettyTyps, _cxs = allArguments |> PrettyTypes.PrettifyTypesN cenv.g
yield
allArguments
prettyTyps
|> List.map (fun arg -> FSharpParameter(cenv, arg, { Name=None; Attribs= [] }, x.DeclarationLocationOpt, false, false, false))
|> makeReadOnlyCollection ]
|> makeReadOnlyCollection
Expand All @@ -1460,8 +1470,8 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
let tau = v.TauType
let argtysl,_ = GetTopTauTypeInFSharpForm cenv.g curriedArgInfos tau range0
let argtysl = if v.IsInstanceMember then argtysl.Tail else argtysl

[ for argtys in argtysl do
let prettyArgtysl = argtysl |> List.map (fun a -> PrettyTypes.PrettifyTypesN1 cenv.g (a, tau))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should prettify tau, not the pieces one by one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand, PrettyTypes.PrettifyTypes1 tau ?
Would we not have to do GetTopTauTypeInFSharpForm and then disregard the head if its an instance?

[ for (_, (argtys,_),_cxs) in prettyArgtysl do
yield
[ for argty, argInfo in argtys do
let isParamArrayArg = HasFSharpAttribute cenv.g cenv.g.attrib_ParamArrayAttribute argInfo.Attribs
Expand Down Expand Up @@ -1490,27 +1500,32 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
// INCOMPLETENESS: Attribs is empty here, so we can't look at return attributes for .NET or F# methods
let retInfo : ArgReprInfo = { Name=None; Attribs= [] }
let rty = p.GetPropertyType(cenv.amap,range0)
let _, rty, _cxs = PrettyTypes.PrettifyTypes1 cenv.g rty
FSharpParameter(cenv, rty, retInfo, x.DeclarationLocationOpt, isParamArrayArg=false, isOutArg=false, isOptionalArg=false)
| M m ->
// INCOMPLETENESS: Attribs is empty here, so we can't look at return attributes for .NET or F# methods
let retInfo : ArgReprInfo = { Name=None; Attribs= [] }
let rty = m.GetFSharpReturnTy(cenv.amap,range0,m.FormalMethodInst)
let _, rty, _cxs = PrettyTypes.PrettifyTypes1 cenv.g rty
FSharpParameter(cenv, rty, retInfo, x.DeclarationLocationOpt, isParamArrayArg=false, isOutArg=false, isOptionalArg=false)
| V v ->
match v.ValReprInfo with
| None ->
let _, tau = v.TypeScheme
if isFunTy cenv.g tau then
let _typeArguments, rty = stripFunTy cenv.g tau
FSharpParameter(cenv, rty, { Name=None; Attribs= [] }, x.DeclarationLocationOpt, isParamArrayArg=false, isOutArg=false, isOptionalArg=false)
let typeArguments, rty = stripFunTy cenv.g tau
let empty : ArgReprInfo = { Name=None; Attribs= [] }
let uncurriedArgInfos = typeArguments |> List.map (fun t -> (t, empty ) )
let _, (_argtys, rty), _csx = PrettyTypes.PrettifyTypesN1 cenv.g (uncurriedArgInfos, rty)
FSharpParameter(cenv, rty, empty, x.DeclarationLocationOpt, isParamArrayArg=false, isOutArg=false, isOptionalArg=false)
else
failwith "not a module let binding or member"
| Some (ValReprInfo(_typars,argInfos,retInfo)) ->
| Some (ValReprInfo(typars,argInfos,retInfo)) ->

let tau = v.TauType
let _,rty = GetTopTauTypeInFSharpForm cenv.g argInfos tau range0

FSharpParameter(cenv, rty, retInfo, x.DeclarationLocationOpt, isParamArrayArg=false, isOutArg=false, isOptionalArg=false)
let c,rty = GetTopTauTypeInFSharpForm cenv.g argInfos tau range0
let (typar, (_types, _, prettyReturn), _cxs) = PrettyTypes.PrettifyTypesNM1 cenv.g ([tau], c, rty)
FSharpParameter(cenv, prettyReturn, retInfo, x.DeclarationLocationOpt, isParamArrayArg=false, isOutArg=false, isOptionalArg=false)


member __.Attributes =
Expand Down