Skip to content

Commit 4e562f3

Browse files
committed
merge
2 parents 790d634 + 0756750 commit 4e562f3

30 files changed

+705
-57
lines changed

src/fsharp/ConstraintSolver.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,7 @@ and CanMemberSigsMatchUpToCheck
18721872
if isArray1DTy g calledArg.CalledArgumentType then
18731873
let paramArrayElemTy = destArrayTy g calledArg.CalledArgumentType
18741874
let reflArgInfo = calledArg.ReflArgInfo // propgate the reflected-arg info to each param array argument
1875-
calledMeth.ParamArrayCallerArgs |> OptionD (IterateD (fun callerArg -> subsumeArg (CalledArg((0,0),false,NotOptional,false,None,reflArgInfo,paramArrayElemTy)) callerArg))
1875+
calledMeth.ParamArrayCallerArgs |> OptionD (IterateD (fun callerArg -> subsumeArg (CalledArg((0,0),false,NotOptional,NoCallerInfo,false,None,reflArgInfo,paramArrayElemTy)) callerArg))
18761876
else
18771877
CompleteD)
18781878

@@ -1895,7 +1895,7 @@ and CanMemberSigsMatchUpToCheck
18951895
let calledArgTy = rfinfo.FieldType
18961896
rfinfo.Name, calledArgTy
18971897

1898-
subsumeArg (CalledArg((-1, 0), false, NotOptional, false, Some (mkSynId m name), ReflectedArgInfo.None, calledArgTy)) caller) )) ++ (fun () ->
1898+
subsumeArg (CalledArg((-1, 0), false, NotOptional, NoCallerInfo, false, Some (mkSynId m name), ReflectedArgInfo.None, calledArgTy)) caller) )) ++ (fun () ->
18991899

19001900
// - Always take the return type into account for
19011901
// -- op_Explicit, op_Implicit

src/fsharp/FSComp.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ chkUnionCaseDefaultAugmentation,"default augmentation of the union case"
264264
438,chkDuplicateMethod,"Duplicate method. The method '%s' has the same name and signature as another method in this type."
265265
438,chkDuplicateMethodWithSuffix,"Duplicate method. The method '%s' has the same name and signature as another method in this type once tuples, functions, units of measure and/or provided types are erased."
266266
439,chkDuplicateMethodCurried,"The method '%s' has curried arguments but has the same name as another method in this type. Methods with curried arguments cannot be overloaded. Consider using a method taking tupled arguments."
267-
440,chkCurriedMethodsCantHaveOutParams,"Methods with curried arguments cannot declare 'out', 'ParamArray', 'optional', 'ReflectedDefinition' or 'byref' arguments"
267+
440,chkCurriedMethodsCantHaveOutParams,"Methods with curried arguments cannot declare 'out', 'ParamArray', 'optional', 'ReflectedDefinition', 'byref', 'CallerLineNumber', 'CallerMemberName', or 'CallerFilePath' arguments"
268268
441,chkDuplicateProperty,"Duplicate property. The property '%s' has the same name and signature as another property in this type."
269269
441,chkDuplicatePropertyWithSuffix,"Duplicate property. The property '%s' has the same name and signature as another property in this type once tuples, functions, units of measure and/or provided types are erased."
270270
442,chkDuplicateMethodInheritedType,"Duplicate method. The abstract method '%s' has the same name and signature as an abstract method in an inherited type."
@@ -1077,6 +1077,8 @@ lexIndentOffForML,"Consider using a file with extension '.ml' or '.mli' instead"
10771077
1243,parsUnexpectedQuotationOperatorInTypeAliasDidYouMeanVerbatimString,"Unexpected quotation operator '<@' in type definition. If you intend to pass a verbatim string as a static argument to a type provider, put a space between the '<' and '@' characters."
10781078
1244,parsErrorParsingAsOperatorName,"Attempted to parse this as an operator name, but failed"
10791079
1245,lexInvalidUnicodeLiteral,"\U%s is not a valid Unicode character escape sequence"
1080+
1246,tcCallerInfoWrongType,"'%s' must be applied to an argument of type '%s', but has been applied to an argument of type '%s'"
1081+
1247,tcCallerInfoNotOptional,"'%s' can only be applied to optional arguments"
10801082
# reshapedmsbuild.fs
10811083
1300,toolLocationHelperUnsupportedFrameworkVersion,"The specified .NET Framework version "%s" is not supported. Please specify a value from the enumeration Microsoft.Build.Utilities.TargetDotNetFrameworkVersion."
10821084
# -----------------------------------------------------------------------------
@@ -1310,3 +1312,4 @@ estApplyStaticArgumentsForMethodNotImplemented,"A type provider implemented GetS
13101312
3203,parsInvalidUseOfRec,"Invalid use of 'rec' keyword"
13111313
3204,tcStructUnionMultiCase,"A union type which is a struct must have only one case."
13121314
3205,tcUseMayNotBeMutable,"This feature is deprecated. A 'use' binding may not be marked 'mutable'."
1315+
3206,CallerMemberNameIsOverriden,"The CallerMemberNameAttribute applied to parameter '%s' will have no effect. It is overridden by the CallerFilePathAttribute."

src/fsharp/MethodCalls.fs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,17 @@ type CalledArg =
6262
{ Position: (int * int)
6363
IsParamArray : bool
6464
OptArgInfo : OptionalArgInfo
65+
CallerInfoInfo : CallerInfoInfo
6566
IsOutArg: bool
6667
ReflArgInfo: ReflectedArgInfo
6768
NameOpt: Ident option
6869
CalledArgumentType : TType }
6970

70-
let CalledArg(pos,isParamArray,optArgInfo,isOutArg,nameOpt,reflArgInfo,calledArgTy) =
71+
let CalledArg(pos,isParamArray,optArgInfo,callerInfoInfo,isOutArg,nameOpt,reflArgInfo,calledArgTy) =
7172
{ Position=pos
7273
IsParamArray=isParamArray
7374
OptArgInfo =optArgInfo
75+
CallerInfoInfo = callerInfoInfo
7476
IsOutArg=isOutArg
7577
ReflArgInfo=reflArgInfo
7678
NameOpt=nameOpt
@@ -198,10 +200,11 @@ type CalledMethArgSet<'T> =
198200
let MakeCalledArgs amap m (minfo:MethInfo) minst =
199201
// Mark up the arguments with their position, so we can sort them back into order later
200202
let paramDatas = minfo.GetParamDatas(amap, m, minst)
201-
paramDatas |> List.mapiSquared (fun i j (ParamData(isParamArrayArg,isOutArg,optArgInfo,nmOpt,reflArgInfo,typeOfCalledArg)) ->
203+
paramDatas |> List.mapiSquared (fun i j (ParamData(isParamArrayArg,isOutArg,optArgInfo,callerInfoFlags,nmOpt,reflArgInfo,typeOfCalledArg)) ->
202204
{ Position=(i,j)
203205
IsParamArray=isParamArrayArg
204206
OptArgInfo=optArgInfo
207+
CallerInfoInfo = callerInfoFlags
205208
IsOutArg=isOutArg
206209
ReflArgInfo=reflArgInfo
207210
NameOpt=nmOpt

src/fsharp/NicePrint.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ module InfoMemberPrinting =
11931193
/// Format the arguments of a method to a buffer.
11941194
///
11951195
/// This uses somewhat "old fashioned" printf-style buffer printing.
1196-
let formatParamDataToBuffer denv os (ParamData(isParamArray, _isOutArg, optArgInfo, nmOpt, _reflArgInfo, pty)) =
1196+
let formatParamDataToBuffer denv os (ParamData(isParamArray, _isOutArg, optArgInfo, _callerInfoInfo, nmOpt, _reflArgInfo, pty)) =
11971197
let isOptArg = optArgInfo.IsOptional
11981198
match isParamArray, nmOpt, isOptArg, tryDestOptionTy denv.g pty with
11991199
// Layout an optional argument

src/fsharp/PostInferenceChecks.fs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,15 +1334,42 @@ let CheckEntityDefn cenv env (tycon:Entity) =
13341334
else
13351335
errorR(Error(FSComp.SR.chkDuplicateMethodWithSuffix(nm),m))
13361336

1337-
if minfo.NumArgs.Length > 1 && others |> List.exists (fun minfo2 -> not (IsAbstractDefaultPair2 minfo minfo2)) then
1337+
let numCurriedArgSets = minfo.NumArgs.Length
1338+
1339+
if numCurriedArgSets > 1 && others |> List.exists (fun minfo2 -> not (IsAbstractDefaultPair2 minfo minfo2)) then
13381340
errorR(Error(FSComp.SR.chkDuplicateMethodCurried nm,m))
13391341

1340-
if minfo.NumArgs.Length > 1 &&
1342+
if numCurriedArgSets > 1 &&
13411343
(minfo.GetParamDatas(cenv.amap, m, minfo.FormalMethodInst)
1342-
|> List.existsSquared (fun (ParamData(isParamArrayArg, isOutArg, optArgInfo, _, reflArgInfo, ty)) ->
1343-
isParamArrayArg || isOutArg || reflArgInfo.AutoQuote || optArgInfo.IsOptional || isByrefTy cenv.g ty)) then
1344+
|> List.existsSquared (fun (ParamData(isParamArrayArg, isOutArg, optArgInfo, callerInfoInfo, _, reflArgInfo, ty)) ->
1345+
isParamArrayArg || isOutArg || reflArgInfo.AutoQuote || optArgInfo.IsOptional || callerInfoInfo <> NoCallerInfo || isByrefTy cenv.g ty)) then
13441346
errorR(Error(FSComp.SR.chkCurriedMethodsCantHaveOutParams(), m))
13451347

1348+
if numCurriedArgSets = 1 then
1349+
minfo.GetParamDatas(cenv.amap, m, minfo.FormalMethodInst)
1350+
|> List.iterSquared (fun (ParamData(_, _, optArgInfo, callerInfoInfo, _, _, ty)) ->
1351+
match (optArgInfo, callerInfoInfo) with
1352+
| _, NoCallerInfo -> ()
1353+
| NotOptional, _ -> errorR(Error(FSComp.SR.tcCallerInfoNotOptional(callerInfoInfo.ToString()),m))
1354+
| CallerSide(_), CallerLineNumber ->
1355+
if not (typeEquiv cenv.g cenv.g.int32_ty ty) then
1356+
errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfoInfo.ToString(), "int", NicePrint.minimalStringOfType cenv.denv ty),m))
1357+
| CalleeSide, CallerLineNumber ->
1358+
if not ((isOptionTy cenv.g ty) && (typeEquiv cenv.g cenv.g.int32_ty (destOptionTy cenv.g ty))) then
1359+
errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfoInfo.ToString(), "int", NicePrint.minimalStringOfType cenv.denv (destOptionTy cenv.g ty)),m))
1360+
| CallerSide(_), CallerFilePath ->
1361+
if not (typeEquiv cenv.g cenv.g.string_ty ty) then
1362+
errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfoInfo.ToString(), "string", NicePrint.minimalStringOfType cenv.denv ty),m))
1363+
| CalleeSide, CallerFilePath ->
1364+
if not ((isOptionTy cenv.g ty) && (typeEquiv cenv.g cenv.g.string_ty (destOptionTy cenv.g ty))) then
1365+
errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfoInfo.ToString(), "string", NicePrint.minimalStringOfType cenv.denv (destOptionTy cenv.g ty)),m))
1366+
| CallerSide(_), CallerMemberName ->
1367+
if not (typeEquiv cenv.g cenv.g.string_ty ty) then
1368+
errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfoInfo.ToString(), "string", NicePrint.minimalStringOfType cenv.denv ty),m))
1369+
| CalleeSide, CallerMemberName ->
1370+
if not ((isOptionTy cenv.g ty) && (typeEquiv cenv.g cenv.g.string_ty (destOptionTy cenv.g ty))) then
1371+
errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfoInfo.ToString(), "string", NicePrint.minimalStringOfType cenv.denv (destOptionTy cenv.g ty)),m)))
1372+
13461373
for pinfo in immediateProps do
13471374
let nm = pinfo.PropertyName
13481375
let m = (match pinfo.ArbitraryValRef with None -> m | Some vref -> vref.DefinitionRange)

src/fsharp/TcGlobals.fs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ type public TcGlobals =
298298
attrib_PreserveSigAttribute : BuiltinAttribInfo option
299299
attrib_MethodImplAttribute : BuiltinAttribInfo
300300
attrib_ExtensionAttribute : BuiltinAttribInfo
301+
attrib_CallerLineNumberAttribute : BuiltinAttribInfo
302+
attrib_CallerFilePathAttribute : BuiltinAttribInfo
303+
attrib_CallerMemberNameAttribute : BuiltinAttribInfo
304+
301305
tcref_System_Collections_Generic_IList : TyconRef
302306
tcref_System_Collections_Generic_IReadOnlyList : TyconRef
303307
tcref_System_Collections_Generic_ICollection : TyconRef
@@ -1200,7 +1204,10 @@ let mkTcGlobals (compilingFslib,sysCcu,ilg,fslibCcu,directoryToResolveRelativePa
12001204
attrib_PreserveSigAttribute = mkSystemRuntimeInteropServicesAttribute "System.Runtime.InteropServices.PreserveSigAttribute"
12011205
attrib_MethodImplAttribute = mkSystemRuntimeAttrib "System.Runtime.CompilerServices.MethodImplAttribute"
12021206
attrib_ExtensionAttribute = mkSystemRuntimeAttrib "System.Runtime.CompilerServices.ExtensionAttribute"
1203-
1207+
attrib_CallerLineNumberAttribute = mkSystemRuntimeAttrib "System.Runtime.CompilerServices.CallerLineNumberAttribute"
1208+
attrib_CallerFilePathAttribute = mkSystemRuntimeAttrib "System.Runtime.CompilerServices.CallerFilePathAttribute"
1209+
attrib_CallerMemberNameAttribute = mkSystemRuntimeAttrib "System.Runtime.CompilerServices.CallerMemberNameAttribute"
1210+
12041211
attrib_ProjectionParameterAttribute = mk_MFCore_attrib "ProjectionParameterAttribute"
12051212
attrib_CustomOperationAttribute = mk_MFCore_attrib "CustomOperationAttribute"
12061213
attrib_NonSerializedAttribute = if ilg.traits.NonSerializedAttributeScopeRef.IsSome then Some(mkSystemRuntimeAttrib "System.NonSerializedAttribute") else None

0 commit comments

Comments
 (0)