Skip to content

Commit d8ad160

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

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
@@ -464,7 +464,7 @@ let tryGetArgAttribsForCustomOperator ceenv (nm: Ident) =
464464
_joinConditionWord,
465465
methInfo) ->
466466
match methInfo.GetParamAttribs(ceenv.cenv.amap, ceenv.mWhole) with
467-
| [ curriedArgInfo ] -> Some curriedArgInfo // one for the actual argument group
467+
| [ curriedArgInfo ] -> Some (List.map fst curriedArgInfo) // one for the actual argument group
468468
| _ -> None)
469469
|> Some
470470
| _ -> 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
@@ -9842,6 +9842,7 @@ and GenerateMatchingSimpleArgumentTypes (cenv: cenv) (calledMeth: MethInfo) mIte
98429842
let g = cenv.g
98439843
let curriedMethodArgAttribs = calledMeth.GetParamAttribs(cenv.amap, mItem)
98449844
curriedMethodArgAttribs
9845+
|> List.map (List.map fst)
98459846
|> List.map (List.filter isSimpleFormalArg >> NewInferenceTypes g)
98469847

98479848
and UnifyMatchingSimpleArgumentTypes (cenv: cenv) (env: TcEnv) exprTy (calledMeth: MethInfo) mMethExpr mItem =
@@ -9895,7 +9896,7 @@ and TcMethodApplication_SplitSynArguments
98959896
let singleMethodCurriedArgs =
98969897
match candidates with
98979898
| [calledMeth] when List.forall isNil namedCurriedCallerArgs ->
9898-
let curriedCalledArgs = calledMeth.GetParamAttribs(cenv.amap, mItem)
9899+
let curriedCalledArgs = calledMeth.GetParamAttribs(cenv.amap, mItem) |> List.map (List.map fst)
98999900
match curriedCalledArgs with
99009901
| [arg :: _] when isSimpleFormalArg arg -> Some(curriedCalledArgs)
99019902
| _ -> None
@@ -10140,7 +10141,7 @@ and TcAdhocChecksOnLibraryMethods (cenv: cenv) (env: TcEnv) isInstance (finalCal
1014010141
if HasHeadType g g.tcref_System_Collections_Generic_Dictionary finalCalledMethInfo.ApparentEnclosingType &&
1014110142
finalCalledMethInfo.IsConstructor &&
1014210143
not (finalCalledMethInfo.GetParamDatas(cenv.amap, mItem, finalCalledMeth.CalledTyArgs)
10143-
|> List.existsSquared (fun (ParamData(_, _, _, _, _, _, _, ty)) ->
10144+
|> List.existsSquared (fun (ParamData(_, _, _, _, _, _, _, ty), _) ->
1014410145
HasHeadType g g.tcref_System_Collections_Generic_IEqualityComparer ty)) then
1014510146

1014610147
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
@@ -2390,7 +2390,7 @@ let CheckEntityDefn cenv env (tycon: Entity) =
23902390

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

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

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

24222422
let m =

src/Compiler/Checking/infos.fs

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

337-
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo)
337+
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo), argInfo.Attribs
338338

339339
#if !NO_TYPEPROVIDERS
340340

@@ -1290,7 +1290,7 @@ type MethInfo =
12901290
if p.Type.TypeRef.FullName = "System.Int32" then CallerFilePath
12911291
else CallerLineNumber
12921292

1293-
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo) ] ]
1293+
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo), [] ] ]
12941294

12951295
| FSMeth(g, _, vref, _) ->
12961296
GetArgInfosOfMember x.IsCSharpStyleExtensionMember g vref
@@ -1312,7 +1312,7 @@ type MethInfo =
13121312
| None -> ReflectedArgInfo.None
13131313
let isOutArg = p.PUntaint((fun p -> p.IsOut && not p.IsIn), m)
13141314
let isInArg = p.PUntaint((fun p -> p.IsIn && not p.IsOut), m)
1315-
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, NoCallerInfo, reflArgInfo)] ]
1315+
ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, NoCallerInfo, reflArgInfo), [] ] ]
13161316
#endif
13171317

13181318
/// Get the signature of an abstract method slot.
@@ -1423,9 +1423,9 @@ type MethInfo =
14231423
#endif
14241424

14251425
let paramAttribs = x.GetParamAttribs(amap, m)
1426-
(paramAttribs, paramNamesAndTypes) ||> List.map2 (List.map2 (fun info (ParamNameAndType(nmOpt, pty)) ->
1427-
let (ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo)) = info
1428-
ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, nmOpt, reflArgInfo, pty)))
1426+
(paramAttribs, paramNamesAndTypes) ||> List.map2 (List.map2 (fun (info, attribs) (ParamNameAndType(nmOpt, pty)) ->
1427+
let (ParamAttribs(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, reflArgInfo)) = info
1428+
ParamData(isParamArrayArg, isInArg, isOutArg, optArgInfo, callerInfo, nmOpt, reflArgInfo, pty), attribs))
14291429

14301430
member x.HasGenericRetTy() =
14311431
match x with
@@ -1443,7 +1443,7 @@ type MethInfo =
14431443

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

14481448
/// Select all the type parameters of the declaring type of a method.
14491449
///

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
@@ -668,7 +668,7 @@ type internal TypeCheckInfo
668668
match meth.GetParamDatas(amap, m, meth.FormalMethodInst) with
669669
| x :: _ ->
670670
x
671-
|> List.choose (fun (ParamData(_isParamArray, _isInArg, _isOutArg, _optArgInfo, _callerInfo, name, _, ty)) ->
671+
|> List.choose (fun (ParamData(_isParamArray, _isInArg, _isOutArg, _optArgInfo, _callerInfo, name, _, ty), _) ->
672672
match name with
673673
| Some id -> Some(Item.OtherName(Some id, ty, None, Some(ArgumentContainer.Method meth), id.idRange))
674674
| 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)