Skip to content

Commit cb7ce73

Browse files
committed
Don't lose attributes of method parameters (#12)
Temporary fix, remove when upstream dotnet#13786 is fixed.
1 parent 076733a commit cb7ce73

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
@@ -441,7 +441,7 @@ let TcComputationExpression (cenv: cenv) env (overallTy: OverallTy) tpenv (mWhol
441441
argInfos
442442
|> List.map (fun (_nm, __maintainsVarSpaceUsingBind, _maintainsVarSpace, _allowInto, _isLikeZip, _isLikeJoin, _isLikeGroupJoin, _joinConditionWord, methInfo) ->
443443
match methInfo.GetParamAttribs(cenv.amap, mWhole) with
444-
| [curriedArgInfo] -> Some curriedArgInfo // one for the actual argument group
444+
| [curriedArgInfo] -> Some (List.map fst curriedArgInfo) // one for the actual argument group
445445
| _ -> None)
446446
|> Some
447447
| _ -> None

src/Compiler/Checking/CheckExpressions.fs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4114,7 +4114,7 @@ and TcPseudoMemberSpec cenv newOk env synTypes tpenv synMemberSig m =
41144114
let logicalCompiledName = ComputeLogicalName id memberFlags
41154115
for argInfos in curriedArgInfos do
41164116
for argInfo in argInfos do
4117-
let info = CrackParamAttribsInfo g argInfo
4117+
let info, _ = CrackParamAttribsInfo g argInfo
41184118
let (ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo)) = info
41194119
if isParamArrayArg || isInArg || isOutArg || optArgInfo.IsOptional || callerInfo <> CallerInfo.NoCallerInfo || reflArgInfo <> ReflectedArgInfo.None then
41204120
if g.langVersion.SupportsFeature(LanguageFeature.InterfacesWithAbstractStaticMembers) then
@@ -9466,6 +9466,7 @@ and GenerateMatchingSimpleArgumentTypes (cenv: cenv) (calledMeth: MethInfo) mIte
94669466
let g = cenv.g
94679467
let curriedMethodArgAttribs = calledMeth.GetParamAttribs(cenv.amap, mItem)
94689468
curriedMethodArgAttribs
9469+
|> List.map (List.map fst)
94699470
|> List.map (List.filter isSimpleFormalArg >> NewInferenceTypes g)
94709471

94719472
and UnifyMatchingSimpleArgumentTypes (cenv: cenv) (env: TcEnv) exprTy (calledMeth: MethInfo) mMethExpr mItem =
@@ -9519,7 +9520,7 @@ and TcMethodApplication_SplitSynArguments
95199520
let singleMethodCurriedArgs =
95209521
match candidates with
95219522
| [calledMeth] when List.forall isNil namedCurriedCallerArgs ->
9522-
let curriedCalledArgs = calledMeth.GetParamAttribs(cenv.amap, mItem)
9523+
let curriedCalledArgs = calledMeth.GetParamAttribs(cenv.amap, mItem) |> List.map (List.map fst)
95239524
match curriedCalledArgs with
95249525
| [arg :: _] when isSimpleFormalArg arg -> Some(curriedCalledArgs)
95259526
| _ -> None
@@ -9764,7 +9765,7 @@ and TcAdhocChecksOnLibraryMethods (cenv: cenv) (env: TcEnv) isInstance (finalCal
97649765
if HasHeadType g g.tcref_System_Collections_Generic_Dictionary finalCalledMethInfo.ApparentEnclosingType &&
97659766
finalCalledMethInfo.IsConstructor &&
97669767
not (finalCalledMethInfo.GetParamDatas(cenv.amap, mItem, finalCalledMeth.CalledTyArgs)
9767-
|> List.existsSquared (fun (ParamData(_, _, _, _, _, _, _, ty)) ->
9768+
|> List.existsSquared (fun (ParamData(_, _, _, _, _, _, _, ty), _) ->
97689769
HasHeadType g g.tcref_System_Collections_Generic_IEqualityComparer ty)) then
97699770

97709771
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
@@ -478,7 +478,7 @@ type CalledMethArgSet<'T> =
478478
let MakeCalledArgs amap m (minfo: MethInfo) minst =
479479
// Mark up the arguments with their position, so we can sort them back into order later
480480
let paramDatas = minfo.GetParamDatas(amap, m, minst)
481-
paramDatas |> List.mapiSquared (fun i j (ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfoFlags, nmOpt, reflArgInfo, calledArgTy)) ->
481+
paramDatas |> List.mapiSquared (fun i j (ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfoFlags, nmOpt, reflArgInfo, calledArgTy), _) ->
482482
{ Position=(i,j)
483483
IsParamArray=isParamArrayArg
484484
OptArgInfo=optArgInfo

src/Compiler/Checking/NicePrint.fs

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

15761576
let paramsL =
1577-
let paramDatas = minfo.GetParamDatas(amap, m, minst)
1577+
let paramDatas = minfo.GetParamDatas(amap, m, minst) |> List.map (List.map fst)
15781578
if List.forall isNil paramDatas then
15791579
WordL.structUnit
15801580
else
@@ -1617,7 +1617,7 @@ module InfoMemberPrinting =
16171617
PrintTypes.layoutTyparDecls denv idL true minfo.FormalMethodTypars ^^
16181618
SepL.leftParen
16191619

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

src/Compiler/Checking/PostInferenceChecks.fs

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

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

23482348
if numCurriedArgSets = 1 then
23492349
minfo.GetParamDatas(cenv.amap, m, minfo.FormalMethodInst)
2350-
|> List.iterSquared (fun (ParamData(_, isInArg, _, optArgInfo, callerInfo, _, _, ty)) ->
2350+
|> List.iterSquared (fun (ParamData(_, isInArg, _, optArgInfo, callerInfo, _, _, ty), _) ->
23512351
ignore isInArg
23522352
match (optArgInfo, callerInfo) with
23532353
| _, 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

@@ -1204,7 +1204,7 @@ type MethInfo =
12041204
if p.Type.TypeRef.FullName = "System.Int32" then CallerFilePath
12051205
else CallerLineNumber
12061206

1207-
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo) ] ]
1207+
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo), [] ] ]
12081208

12091209
| FSMeth(g, _, vref, _) ->
12101210
GetArgInfosOfMember x.IsCSharpStyleExtensionMember g vref
@@ -1225,7 +1225,7 @@ type MethInfo =
12251225
| None -> ReflectedArgInfo.None
12261226
let isOutArg = p.PUntaint((fun p -> p.IsOut && not p.IsIn), m)
12271227
let isInArg = p.PUntaint((fun p -> p.IsIn && not p.IsOut), m)
1228-
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, NoCallerInfo, reflArgInfo)] ]
1228+
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, NoCallerInfo, reflArgInfo), [] ] ]
12291229
#endif
12301230

12311231
/// Get the signature of an abstract method slot.
@@ -1326,13 +1326,13 @@ type MethInfo =
13261326
#endif
13271327

13281328
let paramAttribs = x.GetParamAttribs(amap, m)
1329-
(paramAttribs, paramNamesAndTypes) ||> List.map2 (List.map2 (fun info (ParamNameAndType(nmOpt, pty)) ->
1329+
(paramAttribs, paramNamesAndTypes) ||> List.map2 (List.map2 (fun (info, attribs) (ParamNameAndType(nmOpt, pty)) ->
13301330
let (ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo)) = info
1331-
ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, nmOpt, reflArgInfo, pty)))
1331+
ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, nmOpt, reflArgInfo, pty), attribs))
13321332

13331333
/// Get the ParamData objects for the parameters of a MethInfo
13341334
member x.HasParamArrayArg(amap, m, minst) =
1335-
x.GetParamDatas(amap, m, minst) |> List.existsSquared (fun (ParamData(isParamArrayArg, _, _, _, _, _, _, _)) -> isParamArrayArg)
1335+
x.GetParamDatas(amap, m, minst) |> List.existsSquared (fun (ParamData(isParamArrayArg, _, _, _, _, _, _, _), _) -> isParamArrayArg)
13361336

13371337
/// Select all the type parameters of the declaring type of a method.
13381338
///

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>]
@@ -515,10 +515,10 @@ type MethInfo =
515515
member GetCustomAttrs: unit -> ILAttributes
516516

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

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

523523
/// Get the parameter names of a MethInfo
524524
member GetParamNames: unit -> string option list list

src/Compiler/Service/FSharpCheckerResults.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ type internal TypeCheckInfo
582582
match meth.GetParamDatas(amap, m, meth.FormalMethodInst) with
583583
| x :: _ ->
584584
x
585-
|> List.choose (fun (ParamData(_isParamArray, _isInArg, _isOutArg, _optArgInfo, _callerInfo, name, _, ty)) ->
585+
|> List.choose (fun (ParamData(_isParamArray, _isInArg, _isOutArg, _optArgInfo, _callerInfo, name, _, ty), _) ->
586586
match name with
587587
| Some id -> Some(Item.OtherName(Some id, ty, None, Some(ArgumentContainer.Method meth), id.idRange))
588588
| None -> None)

src/Compiler/Service/ServiceDeclarationLists.fs

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

810810
| Item.CtorGroup(_, minfo :: _)
811811
| Item.MethodGroup(_, minfo :: _, _) ->
812-
let paramDatas = minfo.GetParamDatas(amap, m, minfo.FormalMethodInst) |> List.head
812+
let paramDatas = minfo.GetParamDatas(amap, m, minfo.FormalMethodInst) |> List.head |> List.map fst
813813
let retTy = minfo.GetFSharpReturnType(amap, m, minfo.FormalMethodInst)
814814
let _prettyTyparInst, prettyParams, prettyRetTyL, _prettyConstraintsL = PrettyParamsOfParamDatas g denv item.TyparInstantiation paramDatas retTy
815815
// 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
@@ -2103,10 +2103,8 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
21032103
| M m | C m ->
21042104
[ for argTys in m.GetParamDatas(cenv.amap, range0, m.FormalMethodInst) do
21052105
yield
2106-
[ for ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, _callerInfo, nmOpt, _reflArgInfo, pty) in argTys do
2107-
// INCOMPLETENESS: Attribs is empty here, so we can't look at attributes for
2108-
// either .NET or F# parameters
2109-
let argInfo: ArgReprInfo = { Name=nmOpt; Attribs=[]; OtherRange=None }
2106+
[ for ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, _callerInfo, nmOpt, _reflArgInfo, pty), attribs in argTys do
2107+
let argInfo: ArgReprInfo = { Name=nmOpt; Attribs=attribs; OtherRange=None }
21102108
let m =
21112109
match nmOpt with
21122110
| Some v -> v.idRange

0 commit comments

Comments
 (0)