Skip to content

Commit f939b71

Browse files
alfonsogarciacaroncave
authored andcommitted
Don't lose attributes of method parameters (#12)
Temporary fix, remove when upstream dotnet#13786 is fixed.
1 parent d89080d commit f939b71

10 files changed

+23
-24
lines changed

src/Compiler/Checking/CheckComputationExpressions.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ let TcComputationExpression (cenv: cenv) env (overallTy: OverallTy) tpenv (mWhol
434434
argInfos
435435
|> List.map (fun (_nm, __maintainsVarSpaceUsingBind, _maintainsVarSpace, _allowInto, _isLikeZip, _isLikeJoin, _isLikeGroupJoin, _joinConditionWord, methInfo) ->
436436
match methInfo.GetParamAttribs(cenv.amap, mWhole) with
437-
| [curriedArgInfo] -> Some curriedArgInfo // one for the actual argument group
437+
| [curriedArgInfo] -> Some (List.map fst curriedArgInfo) // one for the actual argument group
438438
| _ -> None)
439439
|> Some
440440
| _ -> None

src/Compiler/Checking/CheckExpressions.fs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4043,7 +4043,7 @@ and TcPseudoMemberSpec cenv newOk env synTypes tpenv synMemberSig m =
40434043
let logicalCompiledName = ComputeLogicalName id memberFlags
40444044
for argInfos in curriedArgInfos do
40454045
for argInfo in argInfos do
4046-
let info = CrackParamAttribsInfo g argInfo
4046+
let info, _ = CrackParamAttribsInfo g argInfo
40474047
let (ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo)) = info
40484048
if isParamArrayArg || isInArg || isOutArg || optArgInfo.IsOptional || callerInfo <> CallerInfo.NoCallerInfo || reflArgInfo <> ReflectedArgInfo.None then
40494049
if g.langVersion.SupportsFeature(LanguageFeature.InterfacesWithAbstractStaticMembers) then
@@ -9211,6 +9211,7 @@ and GenerateMatchingSimpleArgumentTypes (cenv: cenv) (calledMeth: MethInfo) mIte
92119211
let g = cenv.g
92129212
let curriedMethodArgAttribs = calledMeth.GetParamAttribs(cenv.amap, mItem)
92139213
curriedMethodArgAttribs
9214+
|> List.map (List.map fst)
92149215
|> List.map (List.filter isSimpleFormalArg >> NewInferenceTypes g)
92159216

92169217
and UnifyMatchingSimpleArgumentTypes (cenv: cenv) (env: TcEnv) exprTy (calledMeth: MethInfo) mMethExpr mItem =
@@ -9264,7 +9265,7 @@ and TcMethodApplication_SplitSynArguments
92649265
let singleMethodCurriedArgs =
92659266
match candidates with
92669267
| [calledMeth] when List.forall isNil namedCurriedCallerArgs ->
9267-
let curriedCalledArgs = calledMeth.GetParamAttribs(cenv.amap, mItem)
9268+
let curriedCalledArgs = calledMeth.GetParamAttribs(cenv.amap, mItem) |> List.map (List.map fst)
92689269
match curriedCalledArgs with
92699270
| [arg :: _] when isSimpleFormalArg arg -> Some(curriedCalledArgs)
92709271
| _ -> None
@@ -9499,7 +9500,7 @@ and TcAdhocChecksOnLibraryMethods (cenv: cenv) (env: TcEnv) isInstance (finalCal
94999500
if HasHeadType g g.tcref_System_Collections_Generic_Dictionary finalCalledMethInfo.ApparentEnclosingType &&
95009501
finalCalledMethInfo.IsConstructor &&
95019502
not (finalCalledMethInfo.GetParamDatas(cenv.amap, mItem, finalCalledMeth.CalledTyArgs)
9502-
|> List.existsSquared (fun (ParamData(_, _, _, _, _, _, _, ty)) ->
9503+
|> List.existsSquared (fun (ParamData(_, _, _, _, _, _, _, ty), _) ->
95039504
HasHeadType g g.tcref_System_Collections_Generic_IEqualityComparer ty)) then
95049505

95059506
match argsOfAppTy g finalCalledMethInfo.ApparentEnclosingType with

src/Compiler/Checking/MethodCalls.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ type CalledMethArgSet<'T> =
474474
let MakeCalledArgs amap m (minfo: MethInfo) minst =
475475
// Mark up the arguments with their position, so we can sort them back into order later
476476
let paramDatas = minfo.GetParamDatas(amap, m, minst)
477-
paramDatas |> List.mapiSquared (fun i j (ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfoFlags, nmOpt, reflArgInfo, calledArgTy)) ->
477+
paramDatas |> List.mapiSquared (fun i j (ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfoFlags, nmOpt, reflArgInfo, calledArgTy), _) ->
478478
{ Position=(i,j)
479479
IsParamArray=isParamArrayArg
480480
OptArgInfo=optArgInfo

src/Compiler/Checking/NicePrint.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,7 @@ module InfoMemberPrinting =
14921492
let layout = layoutXmlDocOfMethInfo denv infoReader minfo layout
14931493

14941494
let paramsL =
1495-
let paramDatas = minfo.GetParamDatas(amap, m, minst)
1495+
let paramDatas = minfo.GetParamDatas(amap, m, minst) |> List.map (List.map fst)
14961496
if List.forall isNil paramDatas then
14971497
WordL.structUnit
14981498
else
@@ -1535,7 +1535,7 @@ module InfoMemberPrinting =
15351535
PrintTypes.layoutTyparDecls denv idL true minfo.FormalMethodTypars ^^
15361536
SepL.leftParen
15371537

1538-
let paramDatas = minfo.GetParamDatas (amap, m, minst)
1538+
let paramDatas = minfo.GetParamDatas (amap, m, minst) |> List.map (List.map fst)
15391539
let layout = layout ^^ sepListL RightL.comma ((List.concat >> List.map (layoutParamData denv)) paramDatas)
15401540
layout ^^ RightL.rightParen ^^ WordL.colon ^^ PrintTypes.layoutType denv retTy
15411541

src/Compiler/Checking/PostInferenceChecks.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,13 +2343,13 @@ let CheckEntityDefn cenv env (tycon: Entity) =
23432343

23442344
if numCurriedArgSets > 1 &&
23452345
(minfo.GetParamDatas(cenv.amap, m, minfo.FormalMethodInst)
2346-
|> List.existsSquared (fun (ParamData(isParamArrayArg, _isInArg, isOutArg, optArgInfo, callerInfo, _, reflArgInfo, ty)) ->
2346+
|> List.existsSquared (fun (ParamData(isParamArrayArg, _isInArg, isOutArg, optArgInfo, callerInfo, _, reflArgInfo, ty), _) ->
23472347
isParamArrayArg || isOutArg || reflArgInfo.AutoQuote || optArgInfo.IsOptional || callerInfo <> NoCallerInfo || isByrefLikeTy g m ty)) then
23482348
errorR(Error(FSComp.SR.chkCurriedMethodsCantHaveOutParams(), m))
23492349

23502350
if numCurriedArgSets = 1 then
23512351
minfo.GetParamDatas(cenv.amap, m, minfo.FormalMethodInst)
2352-
|> List.iterSquared (fun (ParamData(_, isInArg, _, optArgInfo, callerInfo, _, _, ty)) ->
2352+
|> List.iterSquared (fun (ParamData(_, isInArg, _, optArgInfo, callerInfo, _, _, ty), _) ->
23532353
ignore isInArg
23542354
match (optArgInfo, callerInfo) with
23552355
| _, NoCallerInfo -> ()

src/Compiler/Checking/infos.fs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ let CrackParamAttribsInfo g (ty: TType, argInfo: ArgReprInfo) =
335335
| ValueSome optTy when typeEquiv g g.int32_ty optTy -> CallerFilePath
336336
| _ -> CallerLineNumber
337337

338-
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo)
338+
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo), argInfo.Attribs
339339

340340
#if !NO_TYPEPROVIDERS
341341

@@ -1170,7 +1170,7 @@ type MethInfo =
11701170
if p.Type.TypeRef.FullName = "System.Int32" then CallerFilePath
11711171
else CallerLineNumber
11721172

1173-
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo) ] ]
1173+
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo), [] ] ]
11741174

11751175
| FSMeth(g, _, vref, _) ->
11761176
GetArgInfosOfMember x.IsCSharpStyleExtensionMember g vref
@@ -1191,7 +1191,7 @@ type MethInfo =
11911191
| None -> ReflectedArgInfo.None
11921192
let isOutArg = p.PUntaint((fun p -> p.IsOut && not p.IsIn), m)
11931193
let isInArg = p.PUntaint((fun p -> p.IsIn && not p.IsOut), m)
1194-
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, NoCallerInfo, reflArgInfo)] ]
1194+
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, NoCallerInfo, reflArgInfo), [] ] ]
11951195
#endif
11961196

11971197
/// Get the signature of an abstract method slot.
@@ -1292,13 +1292,13 @@ type MethInfo =
12921292
#endif
12931293

12941294
let paramAttribs = x.GetParamAttribs(amap, m)
1295-
(paramAttribs, paramNamesAndTypes) ||> List.map2 (List.map2 (fun info (ParamNameAndType(nmOpt, pty)) ->
1295+
(paramAttribs, paramNamesAndTypes) ||> List.map2 (List.map2 (fun (info, attribs) (ParamNameAndType(nmOpt, pty)) ->
12961296
let (ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo)) = info
1297-
ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, nmOpt, reflArgInfo, pty)))
1297+
ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, nmOpt, reflArgInfo, pty), attribs))
12981298

12991299
/// Get the ParamData objects for the parameters of a MethInfo
13001300
member x.HasParamArrayArg(amap, m, minst) =
1301-
x.GetParamDatas(amap, m, minst) |> List.existsSquared (fun (ParamData(isParamArrayArg, _, _, _, _, _, _, _)) -> isParamArrayArg)
1301+
x.GetParamDatas(amap, m, minst) |> List.existsSquared (fun (ParamData(isParamArrayArg, _, _, _, _, _, _, _), _) -> isParamArrayArg)
13021302

13031303
/// Select all the type parameters of the declaring type of a method.
13041304
///

src/Compiler/Checking/infos.fsi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ type ParamAttribs =
146146
callerInfo: CallerInfo *
147147
reflArgInfo: ReflectedArgInfo
148148

149-
val CrackParamAttribsInfo: TcGlobals -> ty: TType * argInfo: ArgReprInfo -> ParamAttribs
149+
val CrackParamAttribsInfo: TcGlobals -> ty: TType * argInfo: ArgReprInfo -> ParamAttribs * Attribs
150150

151151
/// Describes an F# use of an IL type, including the type instantiation associated with the type at a particular usage point.
152152
[<NoComparison; NoEquality>]
@@ -512,10 +512,10 @@ type MethInfo =
512512
member GetCustomAttrs: unit -> ILAttributes
513513

514514
/// Get the parameter attributes of a method info, which get combined with the parameter names and types
515-
member GetParamAttribs: amap: ImportMap * m: range -> ParamAttribs list list
515+
member GetParamAttribs: amap: ImportMap * m: range -> (ParamAttribs * Attribs) list list
516516

517517
/// Get the ParamData objects for the parameters of a MethInfo
518-
member GetParamDatas: amap: ImportMap * m: range * minst: TType list -> ParamData list list
518+
member GetParamDatas: amap: ImportMap * m: range * minst: TType list -> (ParamData * Attribs) list list
519519

520520
/// Get the parameter types of a method info
521521
member GetParamTypes: amap: ImportMap * m: range * minst: TType list -> TType list list

src/Compiler/Service/FSharpCheckerResults.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ type internal TypeCheckInfo
569569
match meth.GetParamDatas(amap, m, meth.FormalMethodInst) with
570570
| x :: _ ->
571571
x
572-
|> List.choose (fun (ParamData (_isParamArray, _isInArg, _isOutArg, _optArgInfo, _callerInfo, name, _, ty)) ->
572+
|> List.choose (fun (ParamData (_isParamArray, _isInArg, _isOutArg, _optArgInfo, _callerInfo, name, _, ty), _) ->
573573
match name with
574574
| Some id -> Some(Item.ArgName(Some id, ty, Some(ArgumentContainer.Method meth), id.idRange))
575575
| None -> None)

src/Compiler/Service/ServiceDeclarationLists.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ module internal DescriptionListsImpl =
782782

783783
| Item.CtorGroup(_, minfo :: _)
784784
| Item.MethodGroup(_, minfo :: _, _) ->
785-
let paramDatas = minfo.GetParamDatas(amap, m, minfo.FormalMethodInst) |> List.head
785+
let paramDatas = minfo.GetParamDatas(amap, m, minfo.FormalMethodInst) |> List.head |> List.map fst
786786
let retTy = minfo.GetFSharpReturnType(amap, m, minfo.FormalMethodInst)
787787
let _prettyTyparInst, prettyParams, prettyRetTyL, _prettyConstraintsL = PrettyParamsOfParamDatas g denv item.TyparInstantiation paramDatas retTy
788788
// FUTURE: prettyTyparInst is the pretty version of the known instantiations of type parameters in the output. It could be returned

src/Compiler/Symbols/Symbols.fs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,10 +2051,8 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
20512051
| M m | C m ->
20522052
[ for argTys in m.GetParamDatas(cenv.amap, range0, m.FormalMethodInst) do
20532053
yield
2054-
[ for ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, _callerInfo, nmOpt, _reflArgInfo, pty) in argTys do
2055-
// INCOMPLETENESS: Attribs is empty here, so we can't look at attributes for
2056-
// either .NET or F# parameters
2057-
let argInfo: ArgReprInfo = { Name=nmOpt; Attribs= [] }
2054+
[ for ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, _callerInfo, nmOpt, _reflArgInfo, pty), attribs in argTys do
2055+
let argInfo: ArgReprInfo = { Name=nmOpt; Attribs=attribs }
20582056
let m =
20592057
match nmOpt with
20602058
| Some v -> v.idRange

0 commit comments

Comments
 (0)