Skip to content

Commit

Permalink
further testing for FCS on List.sum on non-primitive type
Browse files Browse the repository at this point in the history
  • Loading branch information
Don Syme committed Oct 30, 2020
1 parent c4b28a1 commit c8d5dfd
Show file tree
Hide file tree
Showing 4 changed files with 221 additions and 141 deletions.
30 changes: 19 additions & 11 deletions src/fsharp/symbols/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,7 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
// INCOMPLETENESS: Attribs is empty here, so we can't look at attributes for
// either .NET or F# parameters
let argInfo: ArgReprInfo = { Name=nmOpt; Attribs= [] }
yield FSharpParameter(cenv, pty, argInfo, None, x.DeclarationLocationOpt, isParamArrayArg, isInArg, isOutArg, optArgInfo.IsOptional) ]
yield FSharpParameter(cenv, pty, argInfo, None, x.DeclarationLocationOpt, isParamArrayArg, isInArg, isOutArg, optArgInfo.IsOptional, false) ]
|> makeReadOnlyCollection ]
|> makeReadOnlyCollection

Expand All @@ -1891,7 +1891,7 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
// INCOMPLETENESS: Attribs is empty here, so we can't look at attributes for
// either .NET or F# parameters
let argInfo: ArgReprInfo = { Name=nmOpt; Attribs= [] }
yield FSharpParameter(cenv, pty, argInfo, None, x.DeclarationLocationOpt, isParamArrayArg, isInArg, isOutArg, optArgInfo.IsOptional) ]
yield FSharpParameter(cenv, pty, argInfo, None, x.DeclarationLocationOpt, isParamArrayArg, isInArg, isOutArg, optArgInfo.IsOptional, false) ]
|> makeReadOnlyCollection ]
|> makeReadOnlyCollection

Expand Down Expand Up @@ -1923,7 +1923,7 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
let isInArg = HasFSharpAttribute cenv.g cenv.g.attrib_InAttribute argInfo.Attribs && isByrefTy cenv.g argty
let isOutArg = HasFSharpAttribute cenv.g cenv.g.attrib_OutAttribute argInfo.Attribs && isByrefTy cenv.g argty
let isOptionalArg = HasFSharpAttribute cenv.g cenv.g.attrib_OptionalArgumentAttribute argInfo.Attribs
yield FSharpParameter(cenv, argty, argInfo, None, x.DeclarationLocationOpt, isParamArrayArg, isInArg, isOutArg, isOptionalArg) ]
yield FSharpParameter(cenv, argty, argInfo, None, x.DeclarationLocationOpt, isParamArrayArg, isInArg, isOutArg, isOptionalArg, false) ]
|> makeReadOnlyCollection ]
|> makeReadOnlyCollection

Expand Down Expand Up @@ -2115,11 +2115,17 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
| [] -> None
| _ when not (cenv.g.langVersion.SupportsFeature(Features.LanguageFeature.WitnessPassing)) -> None
| _ ->
let g = cenv.g
let witnessTys = GenWitnessTys g witnessInfos
let tys = witnessTys |> List.map (fun ty -> FSharpType(cenv, ty)) |> makeReadOnlyCollection
let witnessParams =
((Set.empty, 0), witnessInfos) ||> List.mapFold (fun (used,i) witnessInfo ->
let paramTy = GenWitnessTy cenv.g witnessInfo
let nm = String.uncapitalize witnessInfo.MemberName
let nm = if used.Contains nm then nm + string i else nm
let argReprInfo : ArgReprInfo = { Attribs=[]; Name=Some (mkSynId x.DeclarationLocation nm) }
let p = FSharpParameter(cenv, paramTy, argReprInfo, None, None, false, false, false, false, true)
p, (used.Add nm, i + 1))
|> fst
let witnessMethName = PrettyNaming.ExtraWitnessMethodName x.CompiledName
Some (witnessMethName, tys)
Some (witnessMethName, makeReadOnlyCollection witnessParams)

type FSharpType(cenv, ty:TType) =

Expand Down Expand Up @@ -2416,7 +2422,7 @@ type FSharpStaticParameter(cenv, sp: Tainted< ExtensionTyping.ProvidedParameterI
"static parameter " + x.Name
#endif

type FSharpParameter(cenv, paramTy: TType, topArgInfo: ArgReprInfo, ownerOpt, ownerRangeOpt, isParamArrayArg, isInArg, isOutArg, isOptionalArg) =
type FSharpParameter(cenv, paramTy: TType, topArgInfo: ArgReprInfo, ownerOpt, ownerRangeOpt, isParamArrayArg, isInArg, isOutArg, isOptionalArg, isWitnessArg) =
inherit FSharpSymbol(cenv,
(fun () ->
let m = defaultArg ownerRangeOpt range0
Expand All @@ -2426,16 +2432,16 @@ type FSharpParameter(cenv, paramTy: TType, topArgInfo: ArgReprInfo, ownerOpt, ow

new (cenv, id, ty, container) =
let argInfo: ArgReprInfo = { Name = Some id; Attribs = [] }
FSharpParameter(cenv, ty, argInfo, container, None, false, false, false, false)
FSharpParameter(cenv, ty, argInfo, container, None, false, false, false, false, false)

new (cenv, ty, argInfo: ArgReprInfo, ownerRangeOpt) =
FSharpParameter(cenv, ty, argInfo, None, ownerRangeOpt, false, false, false, false)
FSharpParameter(cenv, ty, argInfo, None, ownerRangeOpt, false, false, false, false, false)

member _.Name = match topArgInfo.Name with None -> None | Some v -> Some v.idText

member _.cenv: SymbolEnv = cenv

member _.AdjustType ty = FSharpParameter(cenv, ty, topArgInfo, ownerOpt, ownerRangeOpt, isParamArrayArg, isInArg, isOutArg, isOptionalArg)
member _.AdjustType ty = FSharpParameter(cenv, ty, topArgInfo, ownerOpt, ownerRangeOpt, isParamArrayArg, isInArg, isOutArg, isOptionalArg, isWitnessArg)

member _.Type: FSharpType = FSharpType(cenv, paramTy)

Expand Down Expand Up @@ -2466,6 +2472,8 @@ type FSharpParameter(cenv, paramTy: TType, topArgInfo: ArgReprInfo, ownerOpt, ow

member _.IsOptionalArg = isOptionalArg

member _.IsWitnessArg = isWitnessArg

member private x.ValReprInfo = topArgInfo

override x.Equals(other: obj) =
Expand Down
4 changes: 2 additions & 2 deletions src/fsharp/symbols/Symbols.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -908,8 +908,8 @@ type FSharpMemberOrFunctionOrValue =
member FormatLayout: context: FSharpDisplayContext -> Layout

/// Check if this method has an entrpoint that accepts witness arguments and if so return
/// the name of that entrypoint and the types of the witness arguments
member GetWitnessPassingInfo: unit -> (string * IList<FSharpType>) option
/// the name of that entrypoint and information about the additional witness arguments
member GetWitnessPassingInfo: unit -> (string * IList<FSharpParameter>) option

/// A subtype of FSharpSymbol that represents a parameter
[<Class>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22538,7 +22538,7 @@ FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: System.String
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: System.String get_XmlDocSig()
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: range DeclarationLocation
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: range get_DeclarationLocation()
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[System.String,System.Collections.Generic.IList`1[FSharp.Compiler.SourceCodeServices.FSharpType]]] GetWitnessPassingInfo()
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[System.String,System.Collections.Generic.IList`1[FSharp.Compiler.SourceCodeServices.FSharpParameter]]] GetWitnessPassingInfo()
FSharp.Compiler.SourceCodeServices.FSharpMethodGroup: FSharp.Compiler.SourceCodeServices.FSharpMethodGroupItem[] Methods
FSharp.Compiler.SourceCodeServices.FSharpMethodGroup: FSharp.Compiler.SourceCodeServices.FSharpMethodGroupItem[] get_Methods()
FSharp.Compiler.SourceCodeServices.FSharpMethodGroup: System.String MethodName
Expand Down
Loading

0 comments on commit c8d5dfd

Please sign in to comment.