Skip to content

Commit c20d321

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

File tree

10 files changed

+24
-24
lines changed

10 files changed

+24
-24
lines changed

src/Compiler/Checking/Expressions/CheckComputationExpressions.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ let tryGetArgAttribsForCustomOperator ceenv (nm: Ident) =
465465
_joinConditionWord,
466466
methInfo) ->
467467
match methInfo.GetParamAttribs(ceenv.cenv.amap, ceenv.mWhole) with
468-
| [ curriedArgInfo ] -> Some curriedArgInfo // one for the actual argument group
468+
| [ curriedArgInfo ] -> Some (List.map fst curriedArgInfo) // one for the actual argument group
469469
| _ -> None)
470470
|> Some
471471
| _ -> None

src/Compiler/Checking/Expressions/CheckExpressions.fs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4212,7 +4212,7 @@ and TcPseudoMemberSpec cenv newOk env synTypes tpenv synMemberSig m =
42124212
let logicalCompiledName = ComputeLogicalName id memberFlags
42134213
for argInfos in curriedArgInfos do
42144214
for argInfo in argInfos do
4215-
let info = CrackParamAttribsInfo g argInfo
4215+
let info, _ = CrackParamAttribsInfo g argInfo
42164216
let (ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo)) = info
42174217
if isParamArrayArg || isInArg || isOutArg || optArgInfo.IsOptional || callerInfo <> CallerInfo.NoCallerInfo || reflArgInfo <> ReflectedArgInfo.None then
42184218
if g.langVersion.SupportsFeature(LanguageFeature.InterfacesWithAbstractStaticMembers) then
@@ -9844,6 +9844,7 @@ and GenerateMatchingSimpleArgumentTypes (cenv: cenv) (calledMeth: MethInfo) mIte
98449844
let g = cenv.g
98459845
let curriedMethodArgAttribs = calledMeth.GetParamAttribs(cenv.amap, mItem)
98469846
curriedMethodArgAttribs
9847+
|> List.map (List.map fst)
98479848
|> List.map (List.filter isSimpleFormalArg >> NewInferenceTypes g)
98489849

98499850
and UnifyMatchingSimpleArgumentTypes (cenv: cenv) (env: TcEnv) exprTy (calledMeth: MethInfo) mMethExpr mItem =
@@ -9897,7 +9898,7 @@ and TcMethodApplication_SplitSynArguments
98979898
let singleMethodCurriedArgs =
98989899
match candidates with
98999900
| [calledMeth] when List.forall isNil namedCurriedCallerArgs ->
9900-
let curriedCalledArgs = calledMeth.GetParamAttribs(cenv.amap, mItem)
9901+
let curriedCalledArgs = calledMeth.GetParamAttribs(cenv.amap, mItem) |> List.map (List.map fst)
99019902
match curriedCalledArgs with
99029903
| [arg :: _] when isSimpleFormalArg arg -> Some(curriedCalledArgs)
99039904
| _ -> None
@@ -10142,7 +10143,7 @@ and TcAdhocChecksOnLibraryMethods (cenv: cenv) (env: TcEnv) isInstance (finalCal
1014210143
if HasHeadType g g.tcref_System_Collections_Generic_Dictionary finalCalledMethInfo.ApparentEnclosingType &&
1014310144
finalCalledMethInfo.IsConstructor &&
1014410145
not (finalCalledMethInfo.GetParamDatas(cenv.amap, mItem, finalCalledMeth.CalledTyArgs)
10145-
|> List.existsSquared (fun (ParamData(_, _, _, _, _, _, _, ty)) ->
10146+
|> List.existsSquared (fun (ParamData(_, _, _, _, _, _, _, ty), _) ->
1014610147
HasHeadType g g.tcref_System_Collections_Generic_IEqualityComparer ty)) then
1014710148

1014810149
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
@@ -498,7 +498,7 @@ type CalledMethArgSet<'T> =
498498
let MakeCalledArgs amap m (minfo: MethInfo) minst =
499499
// Mark up the arguments with their position, so we can sort them back into order later
500500
let paramDatas = minfo.GetParamDatas(amap, m, minst)
501-
paramDatas |> List.mapiSquared (fun i j (ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfoFlags, nmOpt, reflArgInfo, calledArgTy)) ->
501+
paramDatas |> List.mapiSquared (fun i j (ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfoFlags, nmOpt, reflArgInfo, calledArgTy), _) ->
502502
{ Position=(i,j)
503503
IsParamArray=isParamArrayArg
504504
OptArgInfo=optArgInfo

src/Compiler/Checking/NicePrint.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,7 @@ module InfoMemberPrinting =
16481648
let layout = layoutXmlDocOfMethInfo denv infoReader minfo layout
16491649

16501650
let paramsL =
1651-
let paramDatas = minfo.GetParamDatas(amap, m, minst)
1651+
let paramDatas = minfo.GetParamDatas(amap, m, minst) |> List.map (List.map fst)
16521652
if List.forall isNil paramDatas then
16531653
WordL.structUnit
16541654
else
@@ -1710,6 +1710,7 @@ module InfoMemberPrinting =
17101710
| _ ->
17111711
layout,
17121712
minfo.GetParamDatas (amap, m, minst)
1713+
|> List.map (List.map fst)
17131714
|> List.concat
17141715
|> List.map (layoutParamData denv)
17151716

src/Compiler/Checking/PostInferenceChecks.fs

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

23922392
if numCurriedArgSets > 1 &&
23932393
(minfo.GetParamDatas(cenv.amap, m, minfo.FormalMethodInst)
2394-
|> List.existsSquared (fun (ParamData(isParamArrayArg, _isInArg, isOutArg, optArgInfo, callerInfo, _, reflArgInfo, ty)) ->
2394+
|> List.existsSquared (fun (ParamData(isParamArrayArg, _isInArg, isOutArg, optArgInfo, callerInfo, _, reflArgInfo, ty), _) ->
23952395
isParamArrayArg || isOutArg || reflArgInfo.AutoQuote || optArgInfo.IsOptional || callerInfo <> NoCallerInfo || isByrefLikeTy g m ty)) then
23962396
errorR(Error(FSComp.SR.chkCurriedMethodsCantHaveOutParams(), m))
23972397

@@ -2417,7 +2417,7 @@ let CheckEntityDefn cenv env (tycon: Entity) =
24172417
| ValueNone -> errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfo |> string, desiredTyName, NicePrint.minimalStringOfType cenv.denv ty), m))
24182418

24192419
minfo.GetParamDatas(cenv.amap, m, minfo.FormalMethodInst)
2420-
|> List.iterSquared (fun (ParamData(_, isInArg, _, optArgInfo, callerInfo, nameOpt, _, ty)) ->
2420+
|> List.iterSquared (fun (ParamData(_, isInArg, _, optArgInfo, callerInfo, nameOpt, _, ty), _) ->
24212421
ignore isInArg
24222422

24232423
let m =

src/Compiler/Checking/infos.fs

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

340-
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo)
340+
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo), argInfo.Attribs
341341

342342
#if !NO_TYPEPROVIDERS
343343

@@ -1293,7 +1293,7 @@ type MethInfo =
12931293
if p.Type.TypeRef.FullName = "System.Int32" then CallerFilePath
12941294
else CallerLineNumber
12951295

1296-
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo) ] ]
1296+
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo), [] ] ]
12971297

12981298
| FSMeth(g, _, vref, _) ->
12991299
GetArgInfosOfMember x.IsCSharpStyleExtensionMember g vref
@@ -1315,7 +1315,7 @@ type MethInfo =
13151315
| None -> ReflectedArgInfo.None
13161316
let isOutArg = p.PUntaint((fun p -> p.IsOut && not p.IsIn), m)
13171317
let isInArg = p.PUntaint((fun p -> p.IsIn && not p.IsOut), m)
1318-
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, NoCallerInfo, reflArgInfo)] ]
1318+
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, NoCallerInfo, reflArgInfo), [] ] ]
13191319
#endif
13201320

13211321
/// Get the signature of an abstract method slot.
@@ -1426,9 +1426,9 @@ type MethInfo =
14261426
#endif
14271427

14281428
let paramAttribs = x.GetParamAttribs(amap, m)
1429-
(paramAttribs, paramNamesAndTypes) ||> List.map2 (List.map2 (fun info (ParamNameAndType(nmOpt, pty)) ->
1430-
let (ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo)) = info
1431-
ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, nmOpt, reflArgInfo, pty)))
1429+
(paramAttribs, paramNamesAndTypes) ||> List.map2 (List.map2 (fun (info, attribs) (ParamNameAndType(nmOpt, pty)) ->
1430+
let (ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo)) = info
1431+
ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, nmOpt, reflArgInfo, pty), attribs))
14321432

14331433
member x.HasGenericRetTy() =
14341434
match x with
@@ -1446,7 +1446,7 @@ type MethInfo =
14461446

14471447
/// Get the ParamData objects for the parameters of a MethInfo
14481448
member x.HasParamArrayArg(amap, m, minst) =
1449-
x.GetParamDatas(amap, m, minst) |> List.existsSquared (fun (ParamData(isParamArrayArg, _, _, _, _, _, _, _)) -> isParamArrayArg)
1449+
x.GetParamDatas(amap, m, minst) |> List.existsSquared (fun (ParamData(isParamArrayArg, _, _, _, _, _, _, _), _) -> isParamArrayArg)
14501450

14511451
/// Select all the type parameters of the declaring type of a method.
14521452
///

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>]
@@ -524,10 +524,10 @@ type MethInfo =
524524
member GetCustomAttrs: unit -> ILAttributes
525525

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

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

532532
/// Get the parameter names of a MethInfo
533533
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
@@ -654,7 +654,7 @@ type internal TypeCheckInfo
654654
match meth.GetParamDatas(amap, m, meth.FormalMethodInst) with
655655
| x :: _ ->
656656
x
657-
|> List.choose (fun (ParamData(_isParamArray, _isInArg, _isOutArg, _optArgInfo, _callerInfo, name, _, ty)) ->
657+
|> List.choose (fun (ParamData(_isParamArray, _isInArg, _isOutArg, _optArgInfo, _callerInfo, name, _, ty), _) ->
658658
match name with
659659
| Some id -> Some(Item.OtherName(Some id, ty, None, Some(ArgumentContainer.Method meth), id.idRange))
660660
| None -> None)

src/Compiler/Service/ServiceDeclarationLists.fs

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

801801
| Item.CtorGroup(_, minfo :: _)
802802
| Item.MethodGroup(_, minfo :: _, _) ->
803-
let paramDatas = minfo.GetParamDatas(amap, m, minfo.FormalMethodInst) |> List.head
803+
let paramDatas = minfo.GetParamDatas(amap, m, minfo.FormalMethodInst) |> List.head |> List.map fst
804804
let retTy = minfo.GetFSharpReturnType(amap, m, minfo.FormalMethodInst)
805805
let _prettyTyparInst, prettyParams, prettyRetTyL, _prettyConstraintsL = PrettyParamsOfParamDatas g denv item.TyparInstantiation paramDatas retTy
806806
// 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
@@ -2145,10 +2145,8 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
21452145
| M m | C m ->
21462146
[ for argTys in m.GetParamDatas(cenv.amap, range0, m.FormalMethodInst) do
21472147
yield
2148-
[ for ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, _callerInfo, nmOpt, _reflArgInfo, pty) in argTys do
2149-
// INCOMPLETENESS: Attribs is empty here, so we can't look at attributes for
2150-
// either .NET or F# parameters
2151-
let argInfo: ArgReprInfo = { Name=nmOpt; Attribs=[]; OtherRange=None }
2148+
[ for ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, _callerInfo, nmOpt, _reflArgInfo, pty), attribs in argTys do
2149+
let argInfo: ArgReprInfo = { Name=nmOpt; Attribs=attribs; OtherRange=None }
21522150
let m =
21532151
match nmOpt with
21542152
| Some v -> v.idRange

0 commit comments

Comments
 (0)