Skip to content

Commit 7f4e1d8

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

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
@@ -4093,7 +4093,7 @@ and TcPseudoMemberSpec cenv newOk env synTypes tpenv synMemberSig m =
40934093
let logicalCompiledName = ComputeLogicalName id memberFlags
40944094
for argInfos in curriedArgInfos do
40954095
for argInfo in argInfos do
4096-
let info = CrackParamAttribsInfo g argInfo
4096+
let info, _ = CrackParamAttribsInfo g argInfo
40974097
let (ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo)) = info
40984098
if isParamArrayArg || isInArg || isOutArg || optArgInfo.IsOptional || callerInfo <> CallerInfo.NoCallerInfo || reflArgInfo <> ReflectedArgInfo.None then
40994099
if g.langVersion.SupportsFeature(LanguageFeature.InterfacesWithAbstractStaticMembers) then
@@ -9415,6 +9415,7 @@ and GenerateMatchingSimpleArgumentTypes (cenv: cenv) (calledMeth: MethInfo) mIte
94159415
let g = cenv.g
94169416
let curriedMethodArgAttribs = calledMeth.GetParamAttribs(cenv.amap, mItem)
94179417
curriedMethodArgAttribs
9418+
|> List.map (List.map fst)
94189419
|> List.map (List.filter isSimpleFormalArg >> NewInferenceTypes g)
94199420

94209421
and UnifyMatchingSimpleArgumentTypes (cenv: cenv) (env: TcEnv) exprTy (calledMeth: MethInfo) mMethExpr mItem =
@@ -9468,7 +9469,7 @@ and TcMethodApplication_SplitSynArguments
94689469
let singleMethodCurriedArgs =
94699470
match candidates with
94709471
| [calledMeth] when List.forall isNil namedCurriedCallerArgs ->
9471-
let curriedCalledArgs = calledMeth.GetParamAttribs(cenv.amap, mItem)
9472+
let curriedCalledArgs = calledMeth.GetParamAttribs(cenv.amap, mItem) |> List.map (List.map fst)
94729473
match curriedCalledArgs with
94739474
| [arg :: _] when isSimpleFormalArg arg -> Some(curriedCalledArgs)
94749475
| _ -> None
@@ -9713,7 +9714,7 @@ and TcAdhocChecksOnLibraryMethods (cenv: cenv) (env: TcEnv) isInstance (finalCal
97139714
if HasHeadType g g.tcref_System_Collections_Generic_Dictionary finalCalledMethInfo.ApparentEnclosingType &&
97149715
finalCalledMethInfo.IsConstructor &&
97159716
not (finalCalledMethInfo.GetParamDatas(cenv.amap, mItem, finalCalledMeth.CalledTyArgs)
9716-
|> List.existsSquared (fun (ParamData(_, _, _, _, _, _, _, ty)) ->
9717+
|> List.existsSquared (fun (ParamData(_, _, _, _, _, _, _, ty), _) ->
97179718
HasHeadType g g.tcref_System_Collections_Generic_IEqualityComparer ty)) then
97189719

97199720
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

@@ -1195,7 +1195,7 @@ type MethInfo =
11951195
if p.Type.TypeRef.FullName = "System.Int32" then CallerFilePath
11961196
else CallerLineNumber
11971197

1198-
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo) ] ]
1198+
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo), [] ] ]
11991199

12001200
| FSMeth(g, _, vref, _) ->
12011201
GetArgInfosOfMember x.IsCSharpStyleExtensionMember g vref
@@ -1216,7 +1216,7 @@ type MethInfo =
12161216
| None -> ReflectedArgInfo.None
12171217
let isOutArg = p.PUntaint((fun p -> p.IsOut && not p.IsIn), m)
12181218
let isInArg = p.PUntaint((fun p -> p.IsIn && not p.IsOut), m)
1219-
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, NoCallerInfo, reflArgInfo)] ]
1219+
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, NoCallerInfo, reflArgInfo), [] ] ]
12201220
#endif
12211221

12221222
/// Get the signature of an abstract method slot.
@@ -1317,13 +1317,13 @@ type MethInfo =
13171317
#endif
13181318

13191319
let paramAttribs = x.GetParamAttribs(amap, m)
1320-
(paramAttribs, paramNamesAndTypes) ||> List.map2 (List.map2 (fun info (ParamNameAndType(nmOpt, pty)) ->
1320+
(paramAttribs, paramNamesAndTypes) ||> List.map2 (List.map2 (fun (info, attribs) (ParamNameAndType(nmOpt, pty)) ->
13211321
let (ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo)) = info
1322-
ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, nmOpt, reflArgInfo, pty)))
1322+
ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, nmOpt, reflArgInfo, pty), attribs))
13231323

13241324
/// Get the ParamData objects for the parameters of a MethInfo
13251325
member x.HasParamArrayArg(amap, m, minst) =
1326-
x.GetParamDatas(amap, m, minst) |> List.existsSquared (fun (ParamData(isParamArrayArg, _, _, _, _, _, _, _)) -> isParamArrayArg)
1326+
x.GetParamDatas(amap, m, minst) |> List.existsSquared (fun (ParamData(isParamArrayArg, _, _, _, _, _, _, _), _) -> isParamArrayArg)
13271327

13281328
/// Select all the type parameters of the declaring type of a method.
13291329
///

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 names of a MethInfo
521521
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
@@ -590,7 +590,7 @@ type internal TypeCheckInfo
590590
match meth.GetParamDatas(amap, m, meth.FormalMethodInst) with
591591
| x :: _ ->
592592
x
593-
|> List.choose (fun (ParamData (_isParamArray, _isInArg, _isOutArg, _optArgInfo, _callerInfo, name, _, ty)) ->
593+
|> List.choose (fun (ParamData (_isParamArray, _isInArg, _isOutArg, _optArgInfo, _callerInfo, name, _, ty), _) ->
594594
match name with
595595
| Some id -> Some(Item.OtherName(Some id, ty, None, Some(ArgumentContainer.Method meth), id.idRange))
596596
| None -> None)

src/Compiler/Service/ServiceDeclarationLists.fs

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

811811
| Item.CtorGroup(_, minfo :: _)
812812
| Item.MethodGroup(_, minfo :: _, _) ->
813-
let paramDatas = minfo.GetParamDatas(amap, m, minfo.FormalMethodInst) |> List.head
813+
let paramDatas = minfo.GetParamDatas(amap, m, minfo.FormalMethodInst) |> List.head |> List.map fst
814814
let retTy = minfo.GetFSharpReturnType(amap, m, minfo.FormalMethodInst)
815815
let _prettyTyparInst, prettyParams, prettyRetTyL, _prettyConstraintsL = PrettyParamsOfParamDatas g denv item.TyparInstantiation paramDatas retTy
816816
// 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
@@ -2096,10 +2096,8 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
20962096
| M m | C m ->
20972097
[ for argTys in m.GetParamDatas(cenv.amap, range0, m.FormalMethodInst) do
20982098
yield
2099-
[ for ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, _callerInfo, nmOpt, _reflArgInfo, pty) in argTys do
2100-
// INCOMPLETENESS: Attribs is empty here, so we can't look at attributes for
2101-
// either .NET or F# parameters
2102-
let argInfo: ArgReprInfo = { Name=nmOpt; Attribs=[]; OtherRange=None }
2099+
[ for ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, _callerInfo, nmOpt, _reflArgInfo, pty), attribs in argTys do
2100+
let argInfo: ArgReprInfo = { Name=nmOpt; Attribs=attribs; OtherRange=None }
21032101
let m =
21042102
match nmOpt with
21052103
| Some v -> v.idRange

0 commit comments

Comments
 (0)