提交 41a46add 编写于 作者: A AlekseyTs

C#: Span refinement for Overload Resolution errors. If target is a qualified...

C#: Span refinement for Overload Resolution errors. If target is a qualified name, limit span to its right most part. (changeset 1221372)
上级 5889df70
...@@ -2167,7 +2167,7 @@ private static void CheckRestrictedTypeReceiver(BoundExpression expression, Comp ...@@ -2167,7 +2167,7 @@ private static void CheckRestrictedTypeReceiver(BoundExpression expression, Comp
if (!analyzedArguments.HasErrors) if (!analyzedArguments.HasErrors)
{ {
string name = (object)delegateTypeOpt == null ? methodName : null; string name = (object)delegateTypeOpt == null ? methodName : null;
result.ReportDiagnostics(this, expression.Location, diagnostics, name, result.ReportDiagnostics(this, GetLocationForOverloadResolutionDiagnostic(node, expression), diagnostics, name,
methodGroup.Receiver, analyzedArguments, methodGroup.Methods.ToImmutable(), methodGroup.Receiver, analyzedArguments, methodGroup.Methods.ToImmutable(),
typeContainingConstructor: null, delegateTypeBeingInvoked: delegateTypeOpt, typeContainingConstructor: null, delegateTypeBeingInvoked: delegateTypeOpt,
queryClause: queryClause); queryClause: queryClause);
...@@ -2301,6 +2301,26 @@ private static void CheckRestrictedTypeReceiver(BoundExpression expression, Comp ...@@ -2301,6 +2301,26 @@ private static void CheckRestrictedTypeReceiver(BoundExpression expression, Comp
} }
} }
/// <param name="node">Invocation syntax node.</param>
/// <param name="expression">The syntax for the invoked method, including receiver.</param>
private Location GetLocationForOverloadResolutionDiagnostic(CSharpSyntaxNode node, CSharpSyntaxNode expression)
{
if (node != expression)
{
switch (expression.CSharpKind())
{
case SyntaxKind.QualifiedName:
return ((QualifiedNameSyntax)expression).Right.GetLocation();
case SyntaxKind.SimpleMemberAccessExpression:
case SyntaxKind.PointerMemberAccessExpression:
return ((MemberAccessExpressionSyntax)expression).Name.GetLocation();
}
}
return expression.GetLocation();
}
/// <summary> /// <summary>
/// Replace a BoundTypeOrValueExpression with a BoundExpression for either a type (if useType is true) /// Replace a BoundTypeOrValueExpression with a BoundExpression for either a type (if useType is true)
/// or a value (if useType is false). Any other node is unmodified. /// or a value (if useType is false). Any other node is unmodified.
......
...@@ -1487,7 +1487,7 @@ void Test() ...@@ -1487,7 +1487,7 @@ void Test()
comp3.VerifyDiagnostics( comp3.VerifyDiagnostics(
// (7,9): error CS7036: There is no argument given that corresponds to the required formal parameter 'a' of 'B.F(int[])' // (7,9): error CS7036: There is no argument given that corresponds to the required formal parameter 'a' of 'B.F(int[])'
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "c.F").WithArguments("a", "B.F(int[])").WithLocation(7, 9), Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "F").WithArguments("a", "B.F(int[])").WithLocation(7, 11),
// (8,20): error CS1061: 'object' does not contain a definition for 'Bar' and no extension method 'Bar' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) // (8,20): error CS1061: 'object' does not contain a definition for 'Bar' and no extension method 'Bar' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "Bar").WithArguments("object", "Bar").WithLocation(8, 20), Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "Bar").WithArguments("object", "Bar").WithLocation(8, 20),
// (10,17): error CS7036: There is no argument given that corresponds to the required formal parameter 'a' of 'B.this[int, int[]]' // (10,17): error CS7036: There is no argument given that corresponds to the required formal parameter 'a' of 'B.this[int, int[]]'
......
...@@ -822,7 +822,7 @@ public void Test() ...@@ -822,7 +822,7 @@ public void Test()
.VerifyDiagnostics( .VerifyDiagnostics(
// (26,9): error CS0121: The call is ambiguous between the following methods or properties: 'IBase1.BaseFoo()' and 'IBase2.BaseFoo()' // (26,9): error CS0121: The call is ambiguous between the following methods or properties: 'IBase1.BaseFoo()' and 'IBase2.BaseFoo()'
// ((IInterface)c).BaseFoo(); // ((IInterface)c).BaseFoo();
Diagnostic(ErrorCode.ERR_AmbigCall, "((IInterface)c).BaseFoo").WithArguments("IBase1.BaseFoo()", "IBase2.BaseFoo()")); Diagnostic(ErrorCode.ERR_AmbigCall, "BaseFoo").WithArguments("IBase1.BaseFoo()", "IBase2.BaseFoo()"));
} }
......
...@@ -97,7 +97,7 @@ static void Main() ...@@ -97,7 +97,7 @@ static void Main()
CreateCompilationWithMscorlib(source).VerifyDiagnostics( CreateCompilationWithMscorlib(source).VerifyDiagnostics(
// (22,9): error CS0121: The call is ambiguous between the following methods or properties: 'Base<TLong, TInt>.Method(TLong, int)' and 'Base<TLong, TInt>.Method(long, TInt)' // (22,9): error CS0121: The call is ambiguous between the following methods or properties: 'Base<TLong, TInt>.Method(TLong, int)' and 'Base<TLong, TInt>.Method(long, TInt)'
// new Derived2().Method(1L, 2); //CS0121 // new Derived2().Method(1L, 2); //CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "new Derived2().Method").WithArguments("Base<TLong, TInt>.Method(TLong, int)", "Base<TLong, TInt>.Method(long, TInt)")); Diagnostic(ErrorCode.ERR_AmbigCall, "Method").WithArguments("Base<TLong, TInt>.Method(TLong, int)", "Base<TLong, TInt>.Method(long, TInt)"));
} }
[Fact] [Fact]
...@@ -200,7 +200,7 @@ public override void Method(int a, long b) ...@@ -200,7 +200,7 @@ public override void Method(int a, long b)
Diagnostic(ErrorCode.ERR_UnimplementedAbstractMethod, "Derived").WithArguments("Derived", "Base<int, int>.Method(int, int)"), Diagnostic(ErrorCode.ERR_UnimplementedAbstractMethod, "Derived").WithArguments("Derived", "Base<int, int>.Method(int, int)"),
// (21,9): error CS0121: The call is ambiguous between the following methods or properties: 'Base<T, U>.Method(T, U)' and 'Base<T, U>.Method(U, T)' // (21,9): error CS0121: The call is ambiguous between the following methods or properties: 'Base<T, U>.Method(T, U)' and 'Base<T, U>.Method(U, T)'
// base.Method(1, 1); // base.Method(1, 1);
Diagnostic(ErrorCode.ERR_AmbigCall, "base.Method").WithArguments("Base<T, U>.Method(T, U)", "Base<T, U>.Method(U, T)")); Diagnostic(ErrorCode.ERR_AmbigCall, "Method").WithArguments("Base<T, U>.Method(T, U)", "Base<T, U>.Method(U, T)"));
} }
[Fact] [Fact]
...@@ -299,7 +299,7 @@ void Test1() ...@@ -299,7 +299,7 @@ void Test1()
var asm = TestReferences.SymbolsTests.CustomModifiers.ModoptTests; var asm = TestReferences.SymbolsTests.CustomModifiers.ModoptTests;
CreateCompilationWithMscorlib(text, new[] { asm }).VerifyDiagnostics( CreateCompilationWithMscorlib(text, new[] { asm }).VerifyDiagnostics(
Diagnostic(ErrorCode.ERR_AmbigCall, "obj.M").WithArguments("Metadata.LeastModoptsWinAmbiguous.M(byte, byte)", "Metadata.LeastModoptsWinAmbiguous.M(byte, byte)") Diagnostic(ErrorCode.ERR_AmbigCall, "M").WithArguments("Metadata.LeastModoptsWinAmbiguous.M(byte, byte)", "Metadata.LeastModoptsWinAmbiguous.M(byte, byte)")
); );
} }
...@@ -391,7 +391,7 @@ static void Main() ...@@ -391,7 +391,7 @@ static void Main()
CreateCompilationWithMscorlib(text, new[] { asm }).VerifyDiagnostics( CreateCompilationWithMscorlib(text, new[] { asm }).VerifyDiagnostics(
// (11,9): error CS0570: 'Metadata.Modreq.M(?)' is not supported by the language // (11,9): error CS0570: 'Metadata.Modreq.M(?)' is not supported by the language
// new D().M(11); // Dev10: error CS0570: 'M' is not supported by the language // new D().M(11); // Dev10: error CS0570: 'M' is not supported by the language
Diagnostic(ErrorCode.ERR_BindToBogus, "new D().M").WithArguments("Metadata.Modreq.M(?)") Diagnostic(ErrorCode.ERR_BindToBogus, "M").WithArguments("Metadata.Modreq.M(?)")
); );
} }
...@@ -1134,16 +1134,16 @@ public static void Main(string[] args) ...@@ -1134,16 +1134,16 @@ public static void Main(string[] args)
// (9,9): error CS0121: The call is ambiguous between the following methods or properties: 'CG<T>.F(T)' and 'CG<T>.F(T)' // (9,9): error CS0121: The call is ambiguous between the following methods or properties: 'CG<T>.F(T)' and 'CG<T>.F(T)'
// base.F(c); // base.F(c);
Diagnostic(ErrorCode.ERR_AmbigCall, "base.F").WithArguments("CG<T>.F(T)", "CG<T>.F(T)"), Diagnostic(ErrorCode.ERR_AmbigCall, "F").WithArguments("CG<T>.F(T)", "CG<T>.F(T)"),
// (18,9): error CS0121: The call is ambiguous between the following methods or properties: 'CG<T>.F(T)' and 'CG<T>.F(T)' // (18,9): error CS0121: The call is ambiguous between the following methods or properties: 'CG<T>.F(T)' and 'CG<T>.F(T)'
// base.F(c); // base.F(c);
Diagnostic(ErrorCode.ERR_AmbigCall, "base.F").WithArguments("CG<T>.F(T)", "CG<T>.F(T)"), Diagnostic(ErrorCode.ERR_AmbigCall, "F").WithArguments("CG<T>.F(T)", "CG<T>.F(T)"),
// (34,13): error CS0121: The call is ambiguous between the following methods or properties: 'CG<T>.F(T)' and 'CG<T>.F(T)' // (34,13): error CS0121: The call is ambiguous between the following methods or properties: 'CG<T>.F(T)' and 'CG<T>.F(T)'
// e.F(c); // e.F(c);
Diagnostic(ErrorCode.ERR_AmbigCall, "e.F").WithArguments("CG<T>.F(T)", "CG<T>.F(T)"), Diagnostic(ErrorCode.ERR_AmbigCall, "F").WithArguments("CG<T>.F(T)", "CG<T>.F(T)"),
// (43,13): error CS0121: The call is ambiguous between the following methods or properties: 'CG<T>.F(T)' and 'CG<T>.F(T)' // (43,13): error CS0121: The call is ambiguous between the following methods or properties: 'CG<T>.F(T)' and 'CG<T>.F(T)'
// e.F(c); // e.F(c);
Diagnostic(ErrorCode.ERR_AmbigCall, "e.F").WithArguments("CG<T>.F(T)", "CG<T>.F(T)")); Diagnostic(ErrorCode.ERR_AmbigCall, "F").WithArguments("CG<T>.F(T)", "CG<T>.F(T)"));
} }
[Fact] [Fact]
......
...@@ -1300,13 +1300,13 @@ static void M() ...@@ -1300,13 +1300,13 @@ static void M()
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "A").WithArguments("__arglist", "A.A(object, __arglist)").WithLocation(26, 13), Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "A").WithArguments("__arglist", "A.A(object, __arglist)").WithLocation(26, 13),
// (28,9): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'A.M(object, __arglist)' // (28,9): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'A.M(object, __arglist)'
// A.M(__arglist()); // A.M(__arglist());
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "A.M").WithArguments("__arglist", "A.M(object, __arglist)").WithLocation(28, 9), Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M").WithArguments("__arglist", "A.M(object, __arglist)").WithLocation(28, 11),
// (31,13): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'B.B(object, __arglist)' // (31,13): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'B.B(object, __arglist)'
// new B(__arglist()); // new B(__arglist());
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "B").WithArguments("__arglist", "B.B(object, __arglist)").WithLocation(31, 13), Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "B").WithArguments("__arglist", "B.B(object, __arglist)").WithLocation(31, 13),
// (33,9): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'B.M(object, __arglist)' // (33,9): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'B.M(object, __arglist)'
// B.M(__arglist()); // B.M(__arglist());
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "B.M").WithArguments("__arglist", "B.M(object, __arglist)").WithLocation(33, 9), Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M").WithArguments("__arglist", "B.M(object, __arglist)").WithLocation(33, 11),
// (36,13): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'C.C(object, object, __arglist)' // (36,13): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'C.C(object, object, __arglist)'
// new C(__arglist()); // new C(__arglist());
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "C").WithArguments("__arglist", "C.C(object, object, __arglist)").WithLocation(36, 13), Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "C").WithArguments("__arglist", "C.C(object, object, __arglist)").WithLocation(36, 13),
...@@ -1315,10 +1315,10 @@ static void M() ...@@ -1315,10 +1315,10 @@ static void M()
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "C").WithArguments("__arglist", "C.C(object, object, __arglist)").WithLocation(37, 13), Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "C").WithArguments("__arglist", "C.C(object, object, __arglist)").WithLocation(37, 13),
// (39,9): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'C.M(object, object, __arglist)' // (39,9): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'C.M(object, object, __arglist)'
// C.M(__arglist()); // C.M(__arglist());
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "C.M").WithArguments("__arglist", "C.M(object, object, __arglist)").WithLocation(39, 9), Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M").WithArguments("__arglist", "C.M(object, object, __arglist)").WithLocation(39, 11),
// (40,9): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'C.M(object, object, __arglist)' // (40,9): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'C.M(object, object, __arglist)'
// C.M(null, __arglist()); // C.M(null, __arglist());
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "C.M").WithArguments("__arglist", "C.M(object, object, __arglist)").WithLocation(40, 9), Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M").WithArguments("__arglist", "C.M(object, object, __arglist)").WithLocation(40, 11),
// (43,13): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'D.D(object, object, __arglist)' // (43,13): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'D.D(object, object, __arglist)'
// new D(__arglist()); // new D(__arglist());
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "D").WithArguments("__arglist", "D.D(object, object, __arglist)").WithLocation(43, 13), Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "D").WithArguments("__arglist", "D.D(object, object, __arglist)").WithLocation(43, 13),
...@@ -1327,10 +1327,10 @@ static void M() ...@@ -1327,10 +1327,10 @@ static void M()
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "D").WithArguments("__arglist", "D.D(object, object, __arglist)").WithLocation(44, 13), Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "D").WithArguments("__arglist", "D.D(object, object, __arglist)").WithLocation(44, 13),
// (46,9): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'D.M(object, object, __arglist)' // (46,9): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'D.M(object, object, __arglist)'
// D.M(__arglist()); // D.M(__arglist());
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "D.M").WithArguments("__arglist", "D.M(object, object, __arglist)").WithLocation(46, 9), Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M").WithArguments("__arglist", "D.M(object, object, __arglist)").WithLocation(46, 11),
// (47,9): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'D.M(object, object, __arglist)' // (47,9): error CS7036: There is no argument given that corresponds to the required formal parameter '__arglist' of 'D.M(object, object, __arglist)'
// D.M(null, __arglist()); // D.M(null, __arglist());
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "D.M").WithArguments("__arglist", "D.M(object, object, __arglist)").WithLocation(47, 9)); Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M").WithArguments("__arglist", "D.M(object, object, __arglist)").WithLocation(47, 11));
} }
[WorkItem(649808)] [WorkItem(649808)]
......
...@@ -389,10 +389,10 @@ class Awaiter : System.Runtime.CompilerServices.INotifyCompletion ...@@ -389,10 +389,10 @@ class Awaiter : System.Runtime.CompilerServices.INotifyCompletion
CreateCompilationWithMscorlib45(source).VerifyDiagnostics( CreateCompilationWithMscorlib45(source).VerifyDiagnostics(
// (14,9): error CS0121: The call is ambiguous between the following methods or properties: 'Test.GetAwaiter(A)' and 'E.GetAwaiter(A)' // (14,9): error CS0121: The call is ambiguous between the following methods or properties: 'Test.GetAwaiter(A)' and 'E.GetAwaiter(A)'
// new A().GetAwaiter(); // new A().GetAwaiter();
Diagnostic(ErrorCode.ERR_AmbigCall, "new A().GetAwaiter").WithArguments("Test.GetAwaiter(A)", "E.GetAwaiter(A)"), Diagnostic(ErrorCode.ERR_AmbigCall, "GetAwaiter").WithArguments("Test.GetAwaiter(A)", "E.GetAwaiter(A)"),
// (15,9): error CS0121: The call is ambiguous between the following methods or properties: 'Test.GetAwaiter(B)' and 'E.GetAwaiter(B)' // (15,9): error CS0121: The call is ambiguous between the following methods or properties: 'Test.GetAwaiter(B)' and 'E.GetAwaiter(B)'
// new B().GetAwaiter(); // new B().GetAwaiter();
Diagnostic(ErrorCode.ERR_AmbigCall, "new B().GetAwaiter").WithArguments("Test.GetAwaiter(B)", "E.GetAwaiter(B)"), Diagnostic(ErrorCode.ERR_AmbigCall, "GetAwaiter").WithArguments("Test.GetAwaiter(B)", "E.GetAwaiter(B)"),
// (18,9): error CS0121: The call is ambiguous between the following methods or properties: 'Test.GetAwaiter(A)' and 'E.GetAwaiter(A)' // (18,9): error CS0121: The call is ambiguous between the following methods or properties: 'Test.GetAwaiter(A)' and 'E.GetAwaiter(A)'
// await new A(); // await new A();
Diagnostic(ErrorCode.ERR_AmbigCall, "await new A()").WithArguments("Test.GetAwaiter(A)", "E.GetAwaiter(A)"), Diagnostic(ErrorCode.ERR_AmbigCall, "await new A()").WithArguments("Test.GetAwaiter(A)", "E.GetAwaiter(A)"),
......
...@@ -340,7 +340,7 @@ static void M(A a, string s, object o) ...@@ -340,7 +340,7 @@ static void M(A a, string s, object o)
}"; }";
CreateCompilationWithMscorlib(source).VerifyDiagnostics( CreateCompilationWithMscorlib(source).VerifyDiagnostics(
// (18,9): error CS0121: The call is ambiguous between the following methods or properties: 'A.F(object, string)' and 'A.F(string, object)' // (18,9): error CS0121: The call is ambiguous between the following methods or properties: 'A.F(object, string)' and 'A.F(string, object)'
Diagnostic(ErrorCode.ERR_AmbigCall, "a.F").WithArguments("A.F(object, string)", "A.F(string, object)").WithLocation(18, 9), Diagnostic(ErrorCode.ERR_AmbigCall, "F").WithArguments("A.F(object, string)", "A.F(string, object)").WithLocation(18, 11),
// (20,13): error CS1503: Argument 1: cannot convert from 'object' to 'string' // (20,13): error CS1503: Argument 1: cannot convert from 'object' to 'string'
Diagnostic(ErrorCode.ERR_BadArgType, "o").WithArguments("1", "object", "string").WithLocation(20, 13)); Diagnostic(ErrorCode.ERR_BadArgType, "o").WithArguments("1", "object", "string").WithLocation(20, 13));
} }
...@@ -594,7 +594,7 @@ static void M() ...@@ -594,7 +594,7 @@ static void M()
}"; }";
CreateCompilationWithMscorlib(source).VerifyDiagnostics( CreateCompilationWithMscorlib(source).VerifyDiagnostics(
// (12,9): error CS0121: The call is ambiguous between the following methods or properties: 'S.M(double, A)' and 'S.M(double, B)' // (12,9): error CS0121: The call is ambiguous between the following methods or properties: 'S.M(double, A)' and 'S.M(double, B)'
Diagnostic(ErrorCode.ERR_AmbigCall, "S.M").WithArguments("S.M(double, A)", "S.M(double, B)").WithLocation(12, 9), Diagnostic(ErrorCode.ERR_AmbigCall, "M").WithArguments("S.M(double, A)", "S.M(double, B)").WithLocation(12, 11),
// (13,18): error CS1503: Argument 2: cannot convert from 'double' to 'A' // (13,18): error CS1503: Argument 2: cannot convert from 'double' to 'A'
Diagnostic(ErrorCode.ERR_BadArgType, "2.0").WithArguments("2", "double", "A").WithLocation(13, 18)); Diagnostic(ErrorCode.ERR_BadArgType, "2.0").WithArguments("2", "double", "A").WithLocation(13, 18));
} }
......
...@@ -1263,7 +1263,7 @@ public void M(dynamic d, C c) ...@@ -1263,7 +1263,7 @@ public void M(dynamic d, C c)
comp.VerifyDiagnostics( comp.VerifyDiagnostics(
// (9,9): error CS1501: No overload for method 'Foo' takes 1 arguments // (9,9): error CS1501: No overload for method 'Foo' takes 1 arguments
// c.Foo(d); // c.Foo(d);
Diagnostic(ErrorCode.ERR_BadArgCount, "c.Foo").WithArguments("Foo", "1")); Diagnostic(ErrorCode.ERR_BadArgCount, "Foo").WithArguments("Foo", "1"));
} }
[Fact] [Fact]
......
...@@ -258,7 +258,7 @@ static void Main() ...@@ -258,7 +258,7 @@ static void Main()
CreateCompilationWithCustomILSource(csharp, il).VerifyDiagnostics( CreateCompilationWithCustomILSource(csharp, il).VerifyDiagnostics(
// (6,9): error CS1501: No overload for method 'M' takes 2 arguments // (6,9): error CS1501: No overload for method 'M' takes 2 arguments
// new B().M(1, 2); // This would work if B.M was not hide-by-name (since A.M is params) // new B().M(1, 2); // This would work if B.M was not hide-by-name (since A.M is params)
Diagnostic(ErrorCode.ERR_BadArgCount, "new B().M").WithArguments("M", "2")); Diagnostic(ErrorCode.ERR_BadArgCount, "M").WithArguments("M", "2"));
} }
[Fact] [Fact]
......
...@@ -6942,13 +6942,13 @@ public static void Main() ...@@ -6942,13 +6942,13 @@ public static void Main()
Diagnostic(ErrorCode.WRN_ExplicitImplCollision, "Method").WithArguments("Explicit.I1<int, int>.Method<V>(int, System.Func<int, int, V>, int)"), Diagnostic(ErrorCode.WRN_ExplicitImplCollision, "Method").WithArguments("Explicit.I1<int, int>.Method<V>(int, System.Func<int, int, V>, int)"),
// (29,9): error CS0121: The call is ambiguous between the following methods or properties: 'I1<T, U>.Method<V>(T, System.Func<U, T, V>, U)' and 'I1<T, U>.Method<Z>(U, System.Func<T, U, Z>, T)' // (29,9): error CS0121: The call is ambiguous between the following methods or properties: 'I1<T, U>.Method<V>(T, System.Func<U, T, V>, U)' and 'I1<T, U>.Method<Z>(U, System.Func<T, U, Z>, T)'
// i.Method<string>(1, x, 1); // i.Method<string>(1, x, 1);
Diagnostic(ErrorCode.ERR_AmbigCall, "i.Method<string>").WithArguments("I1<T, U>.Method<V>(T, System.Func<U, T, V>, U)", "I1<T, U>.Method<Z>(U, System.Func<T, U, Z>, T)"), Diagnostic(ErrorCode.ERR_AmbigCall, "Method<string>").WithArguments("I1<T, U>.Method<V>(T, System.Func<U, T, V>, U)", "I1<T, U>.Method<Z>(U, System.Func<T, U, Z>, T)"),
// (32,9): error CS0121: The call is ambiguous between the following methods or properties: 'I1<T, U>.Method<V>(T, System.Func<U, T, V>, U)' and 'I1<T, U>.Method<Z>(U, System.Func<T, U, Z>, T)' // (32,9): error CS0121: The call is ambiguous between the following methods or properties: 'I1<T, U>.Method<V>(T, System.Func<U, T, V>, U)' and 'I1<T, U>.Method<Z>(U, System.Func<T, U, Z>, T)'
// i.Method<string>(1, x, 1); // i.Method<string>(1, x, 1);
Diagnostic(ErrorCode.ERR_AmbigCall, "i.Method<string>").WithArguments("I1<T, U>.Method<V>(T, System.Func<U, T, V>, U)", "I1<T, U>.Method<Z>(U, System.Func<T, U, Z>, T)"), Diagnostic(ErrorCode.ERR_AmbigCall, "Method<string>").WithArguments("I1<T, U>.Method<V>(T, System.Func<U, T, V>, U)", "I1<T, U>.Method<Z>(U, System.Func<T, U, Z>, T)"),
// (35,9): error CS0121: The call is ambiguous between the following methods or properties: 'I1<T, U>.Method<V>(T, System.Func<U, T, V>, U)' and 'I1<T, U>.Method<Z>(U, System.Func<T, U, Z>, T)' // (35,9): error CS0121: The call is ambiguous between the following methods or properties: 'I1<T, U>.Method<V>(T, System.Func<U, T, V>, U)' and 'I1<T, U>.Method<Z>(U, System.Func<T, U, Z>, T)'
// i.Method<string>(1, x, 1); // i.Method<string>(1, x, 1);
Diagnostic(ErrorCode.ERR_AmbigCall, "i.Method<string>").WithArguments("I1<T, U>.Method<V>(T, System.Func<U, T, V>, U)", "I1<T, U>.Method<Z>(U, System.Func<T, U, Z>, T)")); Diagnostic(ErrorCode.ERR_AmbigCall, "Method<string>").WithArguments("I1<T, U>.Method<V>(T, System.Func<U, T, V>, U)", "I1<T, U>.Method<Z>(U, System.Func<T, U, Z>, T)"));
} }
[Fact] [Fact]
...@@ -7039,10 +7039,10 @@ public static void Main() ...@@ -7039,10 +7039,10 @@ public static void Main()
Diagnostic(ErrorCode.WRN_NewRequired, "Method").WithArguments("ImplicitInBase.Method(int, System.Func<int, int>, params int[])", "Base.Method(int, System.Func<int, int>, int[])"), Diagnostic(ErrorCode.WRN_NewRequired, "Method").WithArguments("ImplicitInBase.Method(int, System.Func<int, int>, params int[])", "Base.Method(int, System.Func<int, int>, int[])"),
// (34,9): error CS0121: The call is ambiguous between the following methods or properties: 'I1<T, U>.Method(T, U[])' and 'I1<T, U>.Method(U, params T[])' // (34,9): error CS0121: The call is ambiguous between the following methods or properties: 'I1<T, U>.Method(T, U[])' and 'I1<T, U>.Method(U, params T[])'
// i.Method(x, new int[] { x, x, x }); i.Method(x, x, x, x); // i.Method(x, new int[] { x, x, x }); i.Method(x, x, x, x);
Diagnostic(ErrorCode.ERR_AmbigCall, "i.Method").WithArguments("I1<T, U>.Method(T, U[])", "I1<T, U>.Method(U, params T[])"), Diagnostic(ErrorCode.ERR_AmbigCall, "Method").WithArguments("I1<T, U>.Method(T, U[])", "I1<T, U>.Method(U, params T[])"),
// (35,9): error CS0121: The call is ambiguous between the following methods or properties: 'I1<T, U>.Method(T, System.Func<T, U>, U[])' and 'I1<T, U>.Method(U, System.Func<T, U>, params U[])' // (35,9): error CS0121: The call is ambiguous between the following methods or properties: 'I1<T, U>.Method(T, System.Func<T, U>, U[])' and 'I1<T, U>.Method(U, System.Func<T, U>, params U[])'
// i.Method(x, y, new int[] { x, x, x }); i.Method(x, y, x, x, x); // i.Method(x, y, new int[] { x, x, x }); i.Method(x, y, x, x, x);
Diagnostic(ErrorCode.ERR_AmbigCall, "i.Method").WithArguments("I1<T, U>.Method(T, System.Func<T, U>, U[])", "I1<T, U>.Method(U, System.Func<T, U>, params U[])")); Diagnostic(ErrorCode.ERR_AmbigCall, "Method").WithArguments("I1<T, U>.Method(T, System.Func<T, U>, U[])", "I1<T, U>.Method(U, System.Func<T, U>, params U[])"));
} }
......
...@@ -1337,7 +1337,7 @@ static void Main() ...@@ -1337,7 +1337,7 @@ static void Main()
CreateCompilationWithMscorlib(source).VerifyDiagnostics( CreateCompilationWithMscorlib(source).VerifyDiagnostics(
// (25,9): error CS7036: There is no argument given that corresponds to the required formal parameter 'o' of 'D.M(ref object)' // (25,9): error CS7036: There is no argument given that corresponds to the required formal parameter 'o' of 'D.M(ref object)'
// d.M(); //CS1501 // d.M(); //CS1501
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "d.M").WithArguments("o", "D.M(ref object)").WithLocation(25, 9)); Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M").WithArguments("o", "D.M(ref object)").WithLocation(25, 11));
} }
[WorkItem(545337)] [WorkItem(545337)]
...@@ -1661,7 +1661,7 @@ class P ...@@ -1661,7 +1661,7 @@ class P
comp.VerifyDiagnostics( comp.VerifyDiagnostics(
// (11,26): error CS7036: There is no argument given that corresponds to the required formal parameter 'o' of 'I.M(out object)' // (11,26): error CS7036: There is no argument given that corresponds to the required formal parameter 'o' of 'I.M(out object)'
// static void Q(I i) { i.M(); } // static void Q(I i) { i.M(); }
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "i.M").WithArguments("o", "I.M(out object)") Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M").WithArguments("o", "I.M(out object)")
); );
} }
......
...@@ -1011,8 +1011,8 @@ public static void Main2() ...@@ -1011,8 +1011,8 @@ public static void Main2()
} }
}"; }";
CreateCompilationWithMscorlib(source).VerifyDiagnostics( CreateCompilationWithMscorlib(source).VerifyDiagnostics(
Diagnostic(ErrorCode.ERR_BadArgCount, "b.Method2").WithArguments("Method2", "5"), Diagnostic(ErrorCode.ERR_BadArgCount, "Method2").WithArguments("Method2", "5"),
Diagnostic(ErrorCode.ERR_BadArgCount, "d.Method2").WithArguments("Method2", "5")); Diagnostic(ErrorCode.ERR_BadArgCount, "Method2").WithArguments("Method2", "5"));
} }
[Fact] [Fact]
...@@ -1045,8 +1045,8 @@ public static void Main2() ...@@ -1045,8 +1045,8 @@ public static void Main2()
} }
}"; }";
CreateCompilationWithMscorlib(source).VerifyDiagnostics( CreateCompilationWithMscorlib(source).VerifyDiagnostics(
Diagnostic(ErrorCode.ERR_BadArgCount, "d.Method1").WithArguments("Method1", "5"), Diagnostic(ErrorCode.ERR_BadArgCount, "Method1").WithArguments("Method1", "5"),
Diagnostic(ErrorCode.ERR_BadArgCount, "b.Method2").WithArguments("Method2", "5")); Diagnostic(ErrorCode.ERR_BadArgCount, "Method2").WithArguments("Method2", "5"));
} }
[Fact] [Fact]
...@@ -1080,7 +1080,7 @@ public static void Main2() ...@@ -1080,7 +1080,7 @@ public static void Main2()
// (10,15): error CS0466: 'Derived.Base.Method2(Derived, Derived, params Derived[])' should not have a params parameter since 'Base.Method2(Derived, Derived, Derived[])' does not // (10,15): error CS0466: 'Derived.Base.Method2(Derived, Derived, params Derived[])' should not have a params parameter since 'Base.Method2(Derived, Derived, Derived[])' does not
Diagnostic(ErrorCode.ERR_ExplicitImplParams, "Method2").WithArguments("Derived.Base.Method2(Derived, Derived, params Derived[])", "Base.Method2(Derived, Derived, Derived[])"), Diagnostic(ErrorCode.ERR_ExplicitImplParams, "Method2").WithArguments("Derived.Base.Method2(Derived, Derived, params Derived[])", "Base.Method2(Derived, Derived, Derived[])"),
// (19,9): error CS1501: No overload for method 'Method2' takes 5 arguments // (19,9): error CS1501: No overload for method 'Method2' takes 5 arguments
Diagnostic(ErrorCode.ERR_BadArgCount, "b.Method2").WithArguments("Method2", "5")); Diagnostic(ErrorCode.ERR_BadArgCount, "Method2").WithArguments("Method2", "5"));
} }
[WorkItem(540153)] [WorkItem(540153)]
...@@ -1174,8 +1174,8 @@ public static void Main2() ...@@ -1174,8 +1174,8 @@ public static void Main2()
// Same errors as in source case // Same errors as in source case
var comp = CreateCompilationWithCustomILSource(csharpSource, ilSource); var comp = CreateCompilationWithCustomILSource(csharpSource, ilSource);
comp.VerifyDiagnostics( comp.VerifyDiagnostics(
Diagnostic(ErrorCode.ERR_BadArgCount, "b.Method2").WithArguments("Method2", "5"), Diagnostic(ErrorCode.ERR_BadArgCount, "Method2").WithArguments("Method2", "5"),
Diagnostic(ErrorCode.ERR_BadArgCount, "d.Method2").WithArguments("Method2", "5")); Diagnostic(ErrorCode.ERR_BadArgCount, "Method2").WithArguments("Method2", "5"));
} }
[WorkItem(6353, "DevDiv_Projects/Roslyn")] [WorkItem(6353, "DevDiv_Projects/Roslyn")]
...@@ -2986,25 +2986,25 @@ public static void Main() ...@@ -2986,25 +2986,25 @@ public static void Main()
Diagnostic(ErrorCode.ERR_BadArgRef, "c").WithArguments("1", "out"), Diagnostic(ErrorCode.ERR_BadArgRef, "c").WithArguments("1", "out"),
// (117,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M5(ref int)' and 'IRef1.M5(ref long)' // (117,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M5(ref int)' and 'IRef1.M5(ref long)'
// ref1.M5(10); // CS0121 // ref1.M5(10); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M5").WithArguments("IRef1.M5(ref int)", "IRef1.M5(ref long)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M5").WithArguments("IRef1.M5(ref int)", "IRef1.M5(ref long)"),
// (118,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M5(ref int)' and 'IRef1.M5(ref long)' // (118,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M5(ref int)' and 'IRef1.M5(ref long)'
// ref1.M5('c'); // CS0121 // ref1.M5('c'); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M5").WithArguments("IRef1.M5(ref int)", "IRef1.M5(ref long)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M5").WithArguments("IRef1.M5(ref int)", "IRef1.M5(ref long)"),
// (119,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M5(ref int)' and 'IRef1.M5(ref long)' // (119,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M5(ref int)' and 'IRef1.M5(ref long)'
// ref1.M5(i); // CS0121 // ref1.M5(i); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M5").WithArguments("IRef1.M5(ref int)", "IRef1.M5(ref long)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M5").WithArguments("IRef1.M5(ref int)", "IRef1.M5(ref long)"),
// (120,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M5(ref int)' and 'IRef1.M5(ref long)' // (120,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M5(ref int)' and 'IRef1.M5(ref long)'
// ref1.M5(c); // CS0121 // ref1.M5(c); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M5").WithArguments("IRef1.M5(ref int)", "IRef1.M5(ref long)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M5").WithArguments("IRef1.M5(ref int)", "IRef1.M5(ref long)"),
// (121,20): error CS1503: Argument 1: cannot convert from 'ref char' to 'ref int' // (121,20): error CS1503: Argument 1: cannot convert from 'ref char' to 'ref int'
// ref1.M5(ref c); // CS1503 // ref1.M5(ref c); // CS1503
Diagnostic(ErrorCode.ERR_BadArgType, "c").WithArguments("1", "ref char", "ref int"), Diagnostic(ErrorCode.ERR_BadArgType, "c").WithArguments("1", "ref char", "ref int"),
// (128,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M6(ref char)' and 'IRef1.M6(ref long)' // (128,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M6(ref char)' and 'IRef1.M6(ref long)'
// ref1.M6('c'); // CS0121 // ref1.M6('c'); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M6").WithArguments("IRef1.M6(ref char)", "IRef1.M6(ref long)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M6").WithArguments("IRef1.M6(ref char)", "IRef1.M6(ref long)"),
// (129,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M6(ref char)' and 'IRef1.M6(ref long)' // (129,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M6(ref char)' and 'IRef1.M6(ref long)'
// ref1.M6(c); // CS0121 // ref1.M6(c); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M6").WithArguments("IRef1.M6(ref char)", "IRef1.M6(ref long)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M6").WithArguments("IRef1.M6(ref char)", "IRef1.M6(ref long)"),
// (130,20): error CS1503: Argument 1: cannot convert from 'ref int' to 'ref char' // (130,20): error CS1503: Argument 1: cannot convert from 'ref int' to 'ref char'
// ref1.M6(ref i); // CS1503 // ref1.M6(ref i); // CS1503
Diagnostic(ErrorCode.ERR_BadArgType, "i").WithArguments("1", "ref int", "ref char"), Diagnostic(ErrorCode.ERR_BadArgType, "i").WithArguments("1", "ref int", "ref char"),
...@@ -5264,10 +5264,10 @@ public static void Main() ...@@ -5264,10 +5264,10 @@ public static void Main()
Diagnostic(ErrorCode.ERR_BadArgType, "c").WithArguments("1", "ref char", "ref int"), Diagnostic(ErrorCode.ERR_BadArgType, "c").WithArguments("1", "ref char", "ref int"),
// (129,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M4(ref int, long)' and 'IRef1.M4(ref int, ref int)' // (129,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M4(ref int, long)' and 'IRef1.M4(ref int, ref int)'
// ref1.M4(i, i); // CS0121 // ref1.M4(i, i); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M4").WithArguments("IRef1.M4(ref int, long)", "IRef1.M4(ref int, ref int)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M4").WithArguments("IRef1.M4(ref int, long)", "IRef1.M4(ref int, ref int)"),
// (130,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M4(ref int, long)' and 'IRef1.M4(ref int, ref int)' // (130,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M4(ref int, long)' and 'IRef1.M4(ref int, ref int)'
// ref1.M4(i, c); // CS0121 // ref1.M4(i, c); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M4").WithArguments("IRef1.M4(ref int, long)", "IRef1.M4(ref int, ref int)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M4").WithArguments("IRef1.M4(ref int, long)", "IRef1.M4(ref int, ref int)"),
// (131,16): error CS1620: Argument 1 must be passed with the 'ref' keyword // (131,16): error CS1620: Argument 1 must be passed with the 'ref' keyword
// ref1.M4(l, i); // CS1620 // ref1.M4(l, i); // CS1620
Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("1", "ref"), Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("1", "ref"),
...@@ -5279,10 +5279,10 @@ public static void Main() ...@@ -5279,10 +5279,10 @@ public static void Main()
Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("1", "ref"), Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("1", "ref"),
// (134,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M4(ref int, long)' and 'IRef1.M4(ref int, ref int)' // (134,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M4(ref int, long)' and 'IRef1.M4(ref int, ref int)'
// ref1.M4(c, i); // CS0121 // ref1.M4(c, i); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M4").WithArguments("IRef1.M4(ref int, long)", "IRef1.M4(ref int, ref int)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M4").WithArguments("IRef1.M4(ref int, long)", "IRef1.M4(ref int, ref int)"),
// (135,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M4(ref int, long)' and 'IRef1.M4(ref int, ref int)' // (135,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M4(ref int, long)' and 'IRef1.M4(ref int, ref int)'
// ref1.M4(c, c); // CS0121 // ref1.M4(c, c); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M4").WithArguments("IRef1.M4(ref int, long)", "IRef1.M4(ref int, ref int)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M4").WithArguments("IRef1.M4(ref int, long)", "IRef1.M4(ref int, ref int)"),
// (136,16): error CS1620: Argument 1 must be passed with the 'ref' keyword // (136,16): error CS1620: Argument 1 must be passed with the 'ref' keyword
// ref1.M4(l, ref i); // CS1620, CS1615 // ref1.M4(l, ref i); // CS1620, CS1615
Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("1", "ref"), Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("1", "ref"),
...@@ -5327,13 +5327,13 @@ public static void Main() ...@@ -5327,13 +5327,13 @@ public static void Main()
Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "long", "char"), Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "long", "char"),
// (158,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M6(ref int, int)' and 'IRef1.M6(ref long, int)' // (158,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M6(ref int, int)' and 'IRef1.M6(ref long, int)'
// ref1.M6(i, i); // CS0121 // ref1.M6(i, i); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M6").WithArguments("IRef1.M6(ref int, int)", "IRef1.M6(ref long, int)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M6").WithArguments("IRef1.M6(ref int, int)", "IRef1.M6(ref long, int)"),
// (159,19): error CS1503: Argument 2: cannot convert from 'long' to 'int' // (159,19): error CS1503: Argument 2: cannot convert from 'long' to 'int'
// ref1.M6(i, l); // CS1503 // ref1.M6(i, l); // CS1503
Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "long", "int"), Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "long", "int"),
// (160,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M6(ref int, int)' and 'IRef1.M6(ref long, int)' // (160,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M6(ref int, int)' and 'IRef1.M6(ref long, int)'
// ref1.M6(i, c); // CS0121 // ref1.M6(i, c); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M6").WithArguments("IRef1.M6(ref int, int)", "IRef1.M6(ref long, int)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M6").WithArguments("IRef1.M6(ref int, int)", "IRef1.M6(ref long, int)"),
// (161,16): error CS1620: Argument 1 must be passed with the 'ref' keyword // (161,16): error CS1620: Argument 1 must be passed with the 'ref' keyword
// ref1.M6(l, l); // CS1620, CS1503 // ref1.M6(l, l); // CS1620, CS1503
Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("1", "ref"), Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("1", "ref"),
...@@ -5342,13 +5342,13 @@ public static void Main() ...@@ -5342,13 +5342,13 @@ public static void Main()
Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "long", "int"), Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "long", "int"),
// (162,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M6(ref int, int)' and 'IRef1.M6(ref long, int)' // (162,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M6(ref int, int)' and 'IRef1.M6(ref long, int)'
// ref1.M6(c, i); // CS0121 // ref1.M6(c, i); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M6").WithArguments("IRef1.M6(ref int, int)", "IRef1.M6(ref long, int)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M6").WithArguments("IRef1.M6(ref int, int)", "IRef1.M6(ref long, int)"),
// (163,19): error CS1503: Argument 2: cannot convert from 'long' to 'int' // (163,19): error CS1503: Argument 2: cannot convert from 'long' to 'int'
// ref1.M6(c, l); // CS1503 // ref1.M6(c, l); // CS1503
Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "long", "int"), Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "long", "int"),
// (164,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M6(ref int, int)' and 'IRef1.M6(ref long, int)' // (164,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M6(ref int, int)' and 'IRef1.M6(ref long, int)'
// ref1.M6(c, c); // CS0121 // ref1.M6(c, c); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M6").WithArguments("IRef1.M6(ref int, int)", "IRef1.M6(ref long, int)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M6").WithArguments("IRef1.M6(ref int, int)", "IRef1.M6(ref long, int)"),
// (165,23): error CS1503: Argument 2: cannot convert from 'long' to 'int' // (165,23): error CS1503: Argument 2: cannot convert from 'long' to 'int'
// ref1.M6(ref i, l); // CS1503 // ref1.M6(ref i, l); // CS1503
Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "long", "int"), Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "long", "int"),
...@@ -5360,19 +5360,19 @@ public static void Main() ...@@ -5360,19 +5360,19 @@ public static void Main()
Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "long", "int"), Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "long", "int"),
// (173,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M7(ref int, long)' and 'IRef1.M7(ref long, ref int)' // (173,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M7(ref int, long)' and 'IRef1.M7(ref long, ref int)'
// ref1.M7(i, i); // CS0121 // ref1.M7(i, i); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M7").WithArguments("IRef1.M7(ref int, long)", "IRef1.M7(ref long, ref int)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M7").WithArguments("IRef1.M7(ref int, long)", "IRef1.M7(ref long, ref int)"),
// (174,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M7(ref int, long)' and 'IRef1.M7(ref long, ref int)' // (174,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M7(ref int, long)' and 'IRef1.M7(ref long, ref int)'
// ref1.M7(i, c); // CS0121 // ref1.M7(i, c); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M7").WithArguments("IRef1.M7(ref int, long)", "IRef1.M7(ref long, ref int)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M7").WithArguments("IRef1.M7(ref int, long)", "IRef1.M7(ref long, ref int)"),
// (175,16): error CS1620: Argument 1 must be passed with the 'ref' keyword // (175,16): error CS1620: Argument 1 must be passed with the 'ref' keyword
// ref1.M7(l, l); // CS1620 // ref1.M7(l, l); // CS1620
Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("1", "ref"), Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("1", "ref"),
// (176,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M7(ref int, long)' and 'IRef1.M7(ref long, ref int)' // (176,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M7(ref int, long)' and 'IRef1.M7(ref long, ref int)'
// ref1.M7(c, i); // CS0121 // ref1.M7(c, i); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M7").WithArguments("IRef1.M7(ref int, long)", "IRef1.M7(ref long, ref int)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M7").WithArguments("IRef1.M7(ref int, long)", "IRef1.M7(ref long, ref int)"),
// (177,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M7(ref int, long)' and 'IRef1.M7(ref long, ref int)' // (177,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M7(ref int, long)' and 'IRef1.M7(ref long, ref int)'
// ref1.M7(c, c); // CS0121 // ref1.M7(c, c); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M7").WithArguments("IRef1.M7(ref int, long)", "IRef1.M7(ref long, ref int)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M7").WithArguments("IRef1.M7(ref int, long)", "IRef1.M7(ref long, ref int)"),
// (178,23): error CS1615: Argument 2 should not be passed with the 'ref' keyword // (178,23): error CS1615: Argument 2 should not be passed with the 'ref' keyword
// ref1.M7(i, ref l); // CS1615 // ref1.M7(i, ref l); // CS1615
Diagnostic(ErrorCode.ERR_BadArgExtraRef, "l").WithArguments("2", "ref"), Diagnostic(ErrorCode.ERR_BadArgExtraRef, "l").WithArguments("2", "ref"),
...@@ -5393,10 +5393,10 @@ public static void Main() ...@@ -5393,10 +5393,10 @@ public static void Main()
Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("2", "ref"), Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("2", "ref"),
// (189,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M8(long, ref int)' and 'IRef1.M8(ref long, int)' // (189,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M8(long, ref int)' and 'IRef1.M8(ref long, int)'
// ref1.M8(i, c); // CS0121 // ref1.M8(i, c); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M8").WithArguments("IRef1.M8(long, ref int)", "IRef1.M8(ref long, int)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M8").WithArguments("IRef1.M8(long, ref int)", "IRef1.M8(ref long, int)"),
// (190,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M8(long, ref int)' and 'IRef1.M8(ref long, int)' // (190,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M8(long, ref int)' and 'IRef1.M8(ref long, int)'
// ref1.M8(l, i); // CS0121 // ref1.M8(l, i); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M8").WithArguments("IRef1.M8(long, ref int)", "IRef1.M8(ref long, int)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M8").WithArguments("IRef1.M8(long, ref int)", "IRef1.M8(ref long, int)"),
// (191,19): error CS1620: Argument 2 must be passed with the 'ref' keyword // (191,19): error CS1620: Argument 2 must be passed with the 'ref' keyword
// ref1.M8(l, l); // CS1620 // ref1.M8(l, l); // CS1620
Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("2", "ref"), Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("2", "ref"),
...@@ -5405,7 +5405,7 @@ public static void Main() ...@@ -5405,7 +5405,7 @@ public static void Main()
Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("2", "ref"), Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("2", "ref"),
// (193,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M8(long, ref int)' and 'IRef1.M8(ref long, int)' // (193,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M8(long, ref int)' and 'IRef1.M8(ref long, int)'
// ref1.M8(c, c); // CS0121 // ref1.M8(c, c); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M8").WithArguments("IRef1.M8(long, ref int)", "IRef1.M8(ref long, int)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M8").WithArguments("IRef1.M8(long, ref int)", "IRef1.M8(ref long, int)"),
// (194,23): error CS1503: Argument 2: cannot convert from 'ref long' to 'ref int' // (194,23): error CS1503: Argument 2: cannot convert from 'ref long' to 'ref int'
// ref1.M8(i, ref l); // CS1503 // ref1.M8(i, ref l); // CS1503
Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "ref long", "ref int"), Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "ref long", "ref int"),
...@@ -5453,19 +5453,19 @@ public static void Main() ...@@ -5453,19 +5453,19 @@ public static void Main()
Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "ref long", "ref int"), Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "ref long", "ref int"),
// (211,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M9(ref long, ref int)' and 'IRef1.M9(ref int, ref long)' // (211,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M9(ref long, ref int)' and 'IRef1.M9(ref int, ref long)'
// ref1.M9(i, i); // CS0121 // ref1.M9(i, i); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M9").WithArguments("IRef1.M9(ref long, ref int)", "IRef1.M9(ref int, ref long)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M9").WithArguments("IRef1.M9(ref long, ref int)", "IRef1.M9(ref int, ref long)"),
// (212,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M9(ref long, ref int)' and 'IRef1.M9(ref int, ref long)' // (212,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M9(ref long, ref int)' and 'IRef1.M9(ref int, ref long)'
// ref1.M9(i, c); // CS0121 // ref1.M9(i, c); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M9").WithArguments("IRef1.M9(ref long, ref int)", "IRef1.M9(ref int, ref long)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M9").WithArguments("IRef1.M9(ref long, ref int)", "IRef1.M9(ref int, ref long)"),
// (213,19): error CS1620: Argument 2 must be passed with the 'ref' keyword // (213,19): error CS1620: Argument 2 must be passed with the 'ref' keyword
// ref1.M9(l, l); // CS1620 // ref1.M9(l, l); // CS1620
Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("2", "ref"), Diagnostic(ErrorCode.ERR_BadArgRef, "l").WithArguments("2", "ref"),
// (214,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M9(ref long, ref int)' and 'IRef1.M9(ref int, ref long)' // (214,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M9(ref long, ref int)' and 'IRef1.M9(ref int, ref long)'
// ref1.M9(c, i); // CS0121 // ref1.M9(c, i); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M9").WithArguments("IRef1.M9(ref long, ref int)", "IRef1.M9(ref int, ref long)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M9").WithArguments("IRef1.M9(ref long, ref int)", "IRef1.M9(ref int, ref long)"),
// (215,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M9(ref long, ref int)' and 'IRef1.M9(ref int, ref long)' // (215,8): error CS0121: The call is ambiguous between the following methods or properties: 'IRef1.M9(ref long, ref int)' and 'IRef1.M9(ref int, ref long)'
// ref1.M9(c, c); // CS0121 // ref1.M9(c, c); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "ref1.M9").WithArguments("IRef1.M9(ref long, ref int)", "IRef1.M9(ref int, ref long)"), Diagnostic(ErrorCode.ERR_AmbigCall, "M9").WithArguments("IRef1.M9(ref long, ref int)", "IRef1.M9(ref int, ref long)"),
// (216,23): error CS1503: Argument 2: cannot convert from 'ref long' to 'ref int' // (216,23): error CS1503: Argument 2: cannot convert from 'ref long' to 'ref int'
// ref1.M9(l, ref l); // CS1503 // ref1.M9(l, ref l); // CS1503
Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "ref long", "ref int"), Diagnostic(ErrorCode.ERR_BadArgType, "l").WithArguments("2", "ref long", "ref int"),
......
...@@ -407,13 +407,13 @@ static void M() ...@@ -407,13 +407,13 @@ static void M()
} }
}", }",
"'p.Ambiguous' error CS0121: The call is ambiguous between the following methods or properties: 'P.Ambiguous(string, object)' and 'P.Ambiguous(object, string)'", "'Ambiguous' error CS0121: The call is ambiguous between the following methods or properties: 'P.Ambiguous(string, object)' and 'P.Ambiguous(object, string)'",
"'Blah' error CS1061: 'P' does not contain a definition for 'Blah' and no extension method 'Blah' accepting a first argument of type 'P' could be found (are you missing a using directive or an assembly reference?)", "'Blah' error CS1061: 'P' does not contain a definition for 'Blah' and no extension method 'Blah' accepting a first argument of type 'P' could be found (are you missing a using directive or an assembly reference?)",
"'p.Generic' error CS0411: The type arguments for method 'P.Generic<T>()' cannot be inferred from the usage. Try specifying the type arguments explicitly.", "'Generic' error CS0411: The type arguments for method 'P.Generic<T>()' cannot be inferred from the usage. Try specifying the type arguments explicitly.",
"'NotGeneric<int, int>' error CS0308: The non-generic method 'P.NotGeneric()' cannot be used with type arguments", "'NotGeneric<int, int>' error CS0308: The non-generic method 'P.NotGeneric()' cannot be used with type arguments",
"'Generic<int, int>' error CS0305: Using the generic method 'P.Generic<T>()' requires 1 type arguments", "'Generic<int, int>' error CS0305: Using the generic method 'P.Generic<T>()' requires 1 type arguments",
"'frob' error CS1739: The best overload for 'NoParameter' does not have a parameter named 'frob'", "'frob' error CS1739: The best overload for 'NoParameter' does not have a parameter named 'frob'",
"'p.NoParameter' error CS1501: No overload for method 'NoParameter' takes 2 arguments", "'NoParameter' error CS1501: No overload for method 'NoParameter' takes 2 arguments",
"'p.StaticMethod' error CS0176: Member 'P.StaticMethod()' cannot be accessed with an instance reference; qualify it with a type name instead", "'p.StaticMethod' error CS0176: Member 'P.StaticMethod()' cannot be accessed with an instance reference; qualify it with a type name instead",
"'P.NoParameter' error CS0120: An object reference is required for the non-static field, method, or property 'P.NoParameter()'", "'P.NoParameter' error CS0120: An object reference is required for the non-static field, method, or property 'P.NoParameter()'",
......
...@@ -2919,7 +2919,7 @@ public static void Main() ...@@ -2919,7 +2919,7 @@ public static void Main()
CreateCompilationWithMscorlib(text).VerifyDiagnostics( CreateCompilationWithMscorlib(text).VerifyDiagnostics(
// (9,9): error CS0121: The call is ambiguous between the following methods or properties: 'C.f(int, double)' and 'C.f(double, int)' // (9,9): error CS0121: The call is ambiguous between the following methods or properties: 'C.f(int, double)' and 'C.f(double, int)'
// new C().f(1, 1); // CS0121 // new C().f(1, 1); // CS0121
Diagnostic(ErrorCode.ERR_AmbigCall, "new C().f").WithArguments("C.f(int, double)", "C.f(double, int)") Diagnostic(ErrorCode.ERR_AmbigCall, "f").WithArguments("C.f(int, double)", "C.f(double, int)")
); );
} }
...@@ -8961,7 +8961,7 @@ static void M() ...@@ -8961,7 +8961,7 @@ static void M()
// (34,11): error CS0310: 'I' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'C<T>' // (34,11): error CS0310: 'I' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'C<T>'
Diagnostic(ErrorCode.ERR_NewConstraintNotSatisfied, "I").WithArguments("C<T>", "T", "I").WithLocation(34, 11), Diagnostic(ErrorCode.ERR_NewConstraintNotSatisfied, "I").WithArguments("C<T>", "T", "I").WithLocation(34, 11),
// (36,9): error CS0310: 'B' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'E.F<T>(D<T>)' // (36,9): error CS0310: 'B' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'E.F<T>(D<T>)'
Diagnostic(ErrorCode.ERR_NewConstraintNotSatisfied, "E.F").WithArguments("E.F<T>(D<T>)", "T", "B").WithLocation(36, 9), Diagnostic(ErrorCode.ERR_NewConstraintNotSatisfied, "F").WithArguments("E.F<T>(D<T>)", "T", "B").WithLocation(36, 11),
// (38,19): error CS0310: 'B' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'C<T>' // (38,19): error CS0310: 'B' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'C<T>'
Diagnostic(ErrorCode.ERR_NewConstraintNotSatisfied, "B").WithArguments("C<T>", "T", "B").WithLocation(38, 19), Diagnostic(ErrorCode.ERR_NewConstraintNotSatisfied, "B").WithArguments("C<T>", "T", "B").WithLocation(38, 19),
...@@ -8998,7 +8998,7 @@ static void M() ...@@ -8998,7 +8998,7 @@ static void M()
// (38,9): error CS0310: 'B' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'C<T>' // (38,9): error CS0310: 'B' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'C<T>'
// E.F(S.F<C<B>>); // E.F(S.F<C<B>>);
Diagnostic(ErrorCode.ERR_NewConstraintNotSatisfied, "E.F").WithArguments("C<T>", "T", "B"), Diagnostic(ErrorCode.ERR_NewConstraintNotSatisfied, "F").WithArguments("C<T>", "T", "B"),
// (41,9): error CS0310: 'B' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'E.M<T>(object)' // (41,9): error CS0310: 'B' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'E.M<T>(object)'
Diagnostic(ErrorCode.ERR_NewConstraintNotSatisfied, "o.M<B>").WithArguments("E.M<T>(object)", "T", "B").WithLocation(41, 9), Diagnostic(ErrorCode.ERR_NewConstraintNotSatisfied, "o.M<B>").WithArguments("E.M<T>(object)", "T", "B").WithLocation(41, 9),
...@@ -9564,7 +9564,7 @@ public static void Main() ...@@ -9564,7 +9564,7 @@ public static void Main()
} }
"; ";
DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text, DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text,
new ErrorDescription[] { new ErrorDescription { Code = (int)ErrorCode.ERR_CantInferMethTypeArgs, Line = 11, Column = 9 } }); new ErrorDescription[] { new ErrorDescription { Code = (int)ErrorCode.ERR_CantInferMethTypeArgs, Line = 11, Column = 11 } });
} }
[WorkItem(529560)] [WorkItem(529560)]
...@@ -12249,7 +12249,7 @@ static void Main() ...@@ -12249,7 +12249,7 @@ static void Main()
.VerifyDiagnostics( .VerifyDiagnostics(
// (7,17): error CS1061: 'int' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?) // (7,17): error CS1061: 'int' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)
// var q = 1.Select(z => z); // var q = 1.Select(z => z);
Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "1.Select").WithArguments("int", "Select").WithLocation(7, 17)); Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "Select").WithArguments("int", "Select").WithLocation(7, 19));
} }
[Fact] [Fact]
...@@ -12269,9 +12269,9 @@ static void M(object o) ...@@ -12269,9 +12269,9 @@ static void M(object o)
}"; }";
CreateCompilationWithMscorlibAndSystemCore(source).VerifyDiagnostics( CreateCompilationWithMscorlibAndSystemCore(source).VerifyDiagnostics(
// (6,9): error CS1501: No overload for method 'M1' takes 2 arguments // (6,9): error CS1501: No overload for method 'M1' takes 2 arguments
Diagnostic(ErrorCode.ERR_BadArgCount, "o.M1").WithArguments("M1", "2").WithLocation(6, 9), Diagnostic(ErrorCode.ERR_BadArgCount, "M1").WithArguments("M1", "2").WithLocation(6, 11),
// (7,9): error CS1061: 'object' does not contain a definition for 'M2' and no extension method 'M2' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) // (7,9): error CS1061: 'object' does not contain a definition for 'M2' and no extension method 'M2' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "o.M2").WithArguments("object", "M2").WithLocation(7, 9)); Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "M2").WithArguments("object", "M2").WithLocation(7, 11));
} }
[Fact] [Fact]
...@@ -12470,7 +12470,7 @@ public void ExampleMethod() ...@@ -12470,7 +12470,7 @@ public void ExampleMethod()
} }
"; ";
DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text, DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text,
new ErrorDescription[] { new ErrorDescription { Code = (int)ErrorCode.ERR_BadArgCount, Line = 11, Column = 13 } }); new ErrorDescription[] { new ErrorDescription { Code = (int)ErrorCode.ERR_BadArgCount, Line = 11, Column = 16 } });
} }
[Fact] [Fact]
...@@ -15198,7 +15198,7 @@ static class S ...@@ -15198,7 +15198,7 @@ static class S
var compilation = CreateCompilationWithMscorlib(text, references: new[] { SystemCoreRef }); var compilation = CreateCompilationWithMscorlib(text, references: new[] { SystemCoreRef });
compilation.VerifyDiagnostics( compilation.VerifyDiagnostics(
// (5,9): error CS1928: 'float' does not contain a definition for 'F' and the best extension method overload 'S.F(double)' has some invalid arguments // (5,9): error CS1928: 'float' does not contain a definition for 'F' and the best extension method overload 'S.F(double)' has some invalid arguments
Diagnostic(ErrorCode.ERR_BadExtensionArgTypes, "f.F").WithArguments("float", "F", "S.F(double)").WithLocation(5, 9)); Diagnostic(ErrorCode.ERR_BadExtensionArgTypes, "F").WithArguments("float", "F", "S.F(double)").WithLocation(5, 11));
} }
[Fact] [Fact]
......
...@@ -2165,7 +2165,7 @@ static void Main() ...@@ -2165,7 +2165,7 @@ static void Main()
Diagnostic(ErrorCode.ERR_BindToBogus, "Constructors").WithArguments("Constructors.Constructors(?)"), Diagnostic(ErrorCode.ERR_BindToBogus, "Constructors").WithArguments("Constructors.Constructors(?)"),
// (10,9): error CS0570: 'Methods.M(?)' is not supported by the language // (10,9): error CS0570: 'Methods.M(?)' is not supported by the language
// Methods.M(null); // Methods.M(null);
Diagnostic(ErrorCode.ERR_BindToBogus, "Methods.M").WithArguments("Methods.M(?)"), Diagnostic(ErrorCode.ERR_BindToBogus, "M").WithArguments("Methods.M(?)"),
// (12,29): error CS0570: 'Methods.M(?)' is not supported by the language // (12,29): error CS0570: 'Methods.M(?)' is not supported by the language
// Action<string> a2 = Methods.M; // Action<string> a2 = Methods.M;
Diagnostic(ErrorCode.ERR_BindToBogus, "Methods.M").WithArguments("Methods.M(?)"), Diagnostic(ErrorCode.ERR_BindToBogus, "Methods.M").WithArguments("Methods.M(?)"),
......
...@@ -322,13 +322,13 @@ interface I1<T> ...@@ -322,13 +322,13 @@ interface I1<T>
Diagnostic(ErrorCode.ERR_NoTypeDef, "CL3_C2.Test3").WithArguments("CL2_C1", "CL2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"), Diagnostic(ErrorCode.ERR_NoTypeDef, "CL3_C2.Test3").WithArguments("CL2_C1", "CL2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"),
// (166,9): error CS1501: No overload for method 'Test4' takes 0 arguments // (166,9): error CS1501: No overload for method 'Test4' takes 0 arguments
// CL3_C2.Test4(); // CL3_C2.Test4();
Diagnostic(ErrorCode.ERR_BadArgCount, "CL3_C2.Test4").WithArguments("Test4", "0"), Diagnostic(ErrorCode.ERR_BadArgCount, "Test4").WithArguments("Test4", "0"),
// (171,9): error CS0012: The type 'CL2_C1' is defined in an assembly that is not referenced. You must add a reference to assembly 'CL2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. // (171,9): error CS0012: The type 'CL2_C1' is defined in an assembly that is not referenced. You must add a reference to assembly 'CL2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// CL3_C2.Test4(null); // CL3_C2.Test4(null);
Diagnostic(ErrorCode.ERR_NoTypeDef, "CL3_C2.Test4").WithArguments("CL2_C1", "CL2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"), Diagnostic(ErrorCode.ERR_NoTypeDef, "CL3_C2.Test4").WithArguments("CL2_C1", "CL2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"),
// (171,9): error CS0121: The call is ambiguous between the following methods or properties: 'CL3_C2.Test4(CL3_C1)' and 'CL3_C2.Test4(CL3_C3)' // (171,9): error CS0121: The call is ambiguous between the following methods or properties: 'CL3_C2.Test4(CL3_C1)' and 'CL3_C2.Test4(CL3_C3)'
// CL3_C2.Test4(null); // CL3_C2.Test4(null);
Diagnostic(ErrorCode.ERR_AmbigCall, "CL3_C2.Test4").WithArguments("CL3_C2.Test4(CL3_C1)", "CL3_C2.Test4(CL3_C3)"), Diagnostic(ErrorCode.ERR_AmbigCall, "Test4").WithArguments("CL3_C2.Test4(CL3_C1)", "CL3_C2.Test4(CL3_C3)"),
// (177,9): error CS0012: The type 'CL2_C1' is defined in an assembly that is not referenced. You must add a reference to assembly 'CL2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. // (177,9): error CS0012: The type 'CL2_C1' is defined in an assembly that is not referenced. You must add a reference to assembly 'CL2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// y.Test1(); // y.Test1();
Diagnostic(ErrorCode.ERR_NoTypeDef, "y.Test1").WithArguments("CL2_C1", "CL2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"), Diagnostic(ErrorCode.ERR_NoTypeDef, "y.Test1").WithArguments("CL2_C1", "CL2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"),
...@@ -485,10 +485,10 @@ public interface CL3_I1 : CL2_I1 ...@@ -485,10 +485,10 @@ public interface CL3_I1 : CL2_I1
Diagnostic(ErrorCode.ERR_ObjectRequired, "CL3_C2.Test1").WithArguments("CL3_C2.Test1(int)"), Diagnostic(ErrorCode.ERR_ObjectRequired, "CL3_C2.Test1").WithArguments("CL3_C2.Test1(int)"),
// (166,9): error CS1501: No overload for method 'Test4' takes 0 arguments // (166,9): error CS1501: No overload for method 'Test4' takes 0 arguments
// CL3_C2.Test4(); // CL3_C2.Test4();
Diagnostic(ErrorCode.ERR_BadArgCount, "CL3_C2.Test4").WithArguments("Test4", "0"), Diagnostic(ErrorCode.ERR_BadArgCount, "Test4").WithArguments("Test4", "0"),
// (171,9): error CS0121: The call is ambiguous between the following methods or properties: 'CL3_C2.Test4(CL3_C1)' and 'CL3_C2.Test4(CL3_C3)' // (171,9): error CS0121: The call is ambiguous between the following methods or properties: 'CL3_C2.Test4(CL3_C1)' and 'CL3_C2.Test4(CL3_C3)'
// CL3_C2.Test4(null); // CL3_C2.Test4(null);
Diagnostic(ErrorCode.ERR_AmbigCall, "CL3_C2.Test4").WithArguments("CL3_C2.Test4(CL3_C1)", "CL3_C2.Test4(CL3_C3)"), Diagnostic(ErrorCode.ERR_AmbigCall, "Test4").WithArguments("CL3_C2.Test4(CL3_C1)", "CL3_C2.Test4(CL3_C3)"),
// (177,9): error CS0176: Member 'CL3_C2.Test1()' cannot be accessed with an instance reference; qualify it with a type name instead // (177,9): error CS0176: Member 'CL3_C2.Test1()' cannot be accessed with an instance reference; qualify it with a type name instead
// y.Test1(); // y.Test1();
Diagnostic(ErrorCode.ERR_ObjectProhibited, "y.Test1").WithArguments("CL3_C2.Test1()"), Diagnostic(ErrorCode.ERR_ObjectProhibited, "y.Test1").WithArguments("CL3_C2.Test1()"),
......
...@@ -660,40 +660,40 @@ static class S ...@@ -660,40 +660,40 @@ static class S
compilation.VerifyDiagnostics( compilation.VerifyDiagnostics(
// (10,17): error CS1501: No overload for method 'M1' takes 3 arguments // (10,17): error CS1501: No overload for method 'M1' takes 3 arguments
// this.M1(1, 2, 3); // MethodResolutionKind.NoCorrespondingParameter // this.M1(1, 2, 3); // MethodResolutionKind.NoCorrespondingParameter
Diagnostic(ErrorCode.ERR_BadArgCount, "this.M1").WithArguments("M1", "3").WithLocation(10, 17), Diagnostic(ErrorCode.ERR_BadArgCount, "M1").WithArguments("M1", "3").WithLocation(10, 22),
// (11,17): error CS7036: There is no argument given that corresponds to the required formal parameter 'y' of 'N1.N2.C.M2(int, int)' // (11,17): error CS7036: There is no argument given that corresponds to the required formal parameter 'y' of 'N1.N2.C.M2(int, int)'
// this.M2(1); // MethodResolutionKind.RequiredParameterMissing // this.M2(1); // MethodResolutionKind.RequiredParameterMissing
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "this.M2").WithArguments("y", "N1.N2.C.M2(int, int)").WithLocation(11, 17), Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M2").WithArguments("y", "N1.N2.C.M2(int, int)").WithLocation(11, 22),
// (12,28): error CS1503: Argument 2: cannot convert from 'double' to 'int' // (12,28): error CS1503: Argument 2: cannot convert from 'double' to 'int'
// this.M3(1, 2.0); // MethodResolutionKind.BadArguments // this.M3(1, 2.0); // MethodResolutionKind.BadArguments
Diagnostic(ErrorCode.ERR_BadArgType, "2.0").WithArguments("2", "double", "int").WithLocation(12, 28), Diagnostic(ErrorCode.ERR_BadArgType, "2.0").WithArguments("2", "double", "int").WithLocation(12, 28),
// (13,17): error CS0411: The type arguments for method 'N1.N2.C.M4<T>(T, int)' cannot be inferred from the usage. Try specifying the type arguments explicitly. // (13,17): error CS0411: The type arguments for method 'N1.N2.C.M4<T>(T, int)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
// this.M4(null, 2); // MethodResolutionKind.TypeInferenceFailed // this.M4(null, 2); // MethodResolutionKind.TypeInferenceFailed
Diagnostic(ErrorCode.ERR_CantInferMethTypeArgs, "this.M4").WithArguments("N1.N2.C.M4<T>(T, int)").WithLocation(13, 17), Diagnostic(ErrorCode.ERR_CantInferMethTypeArgs, "M4").WithArguments("N1.N2.C.M4<T>(T, int)").WithLocation(13, 22),
// (14,22): error CS0305: Using the generic method 'N1.N2.C.M5<T>(T, int)' requires 1 type arguments // (14,22): error CS0305: Using the generic method 'N1.N2.C.M5<T>(T, int)' requires 1 type arguments
// this.M5<string, string>(null, 2); // Bad arity // this.M5<string, string>(null, 2); // Bad arity
Diagnostic(ErrorCode.ERR_BadArity, "M5<string, string>").WithArguments("N1.N2.C.M5<T>(T, int)", "method", "1").WithLocation(14, 22), Diagnostic(ErrorCode.ERR_BadArity, "M5<string, string>").WithArguments("N1.N2.C.M5<T>(T, int)", "method", "1").WithLocation(14, 22),
// (15,17): error CS0121: The call is ambiguous between the following methods or properties: 'N1.N2.C.M6(object, string)' and 'N1.N2.C.M6(string, object)' // (15,17): error CS0121: The call is ambiguous between the following methods or properties: 'N1.N2.C.M6(object, string)' and 'N1.N2.C.M6(string, object)'
// this.M6(null, null); // Ambiguous // this.M6(null, null); // Ambiguous
Diagnostic(ErrorCode.ERR_AmbigCall, "this.M6").WithArguments("N1.N2.C.M6(object, string)", "N1.N2.C.M6(string, object)").WithLocation(15, 17), Diagnostic(ErrorCode.ERR_AmbigCall, "M6").WithArguments("N1.N2.C.M6(object, string)", "N1.N2.C.M6(string, object)").WithLocation(15, 22),
// (41,17): error CS1501: No overload for method 'M1' takes 3 arguments // (41,17): error CS1501: No overload for method 'M1' takes 3 arguments
// this.M1(1, 2, 3); // MethodResolutionKind.NoCorrespondingParameter // this.M1(1, 2, 3); // MethodResolutionKind.NoCorrespondingParameter
Diagnostic(ErrorCode.ERR_BadArgCount, "this.M1").WithArguments("M1", "3").WithLocation(41, 17), Diagnostic(ErrorCode.ERR_BadArgCount, "M1").WithArguments("M1", "3").WithLocation(41, 22),
// (42,17): error CS7036: There is no argument given that corresponds to the required formal parameter 'y' of 'N1.N2.C.M2(int, int)' // (42,17): error CS7036: There is no argument given that corresponds to the required formal parameter 'y' of 'N1.N2.C.M2(int, int)'
// this.M2(1); // MethodResolutionKind.RequiredParameterMissing // this.M2(1); // MethodResolutionKind.RequiredParameterMissing
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "this.M2").WithArguments("y", "N1.N2.C.M2(int, int)").WithLocation(42, 17), Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M2").WithArguments("y", "N1.N2.C.M2(int, int)").WithLocation(42, 22),
// (43,28): error CS1503: Argument 2: cannot convert from 'double' to 'int' // (43,28): error CS1503: Argument 2: cannot convert from 'double' to 'int'
// this.M3(1, 2.0); // MethodResolutionKind.BadArguments // this.M3(1, 2.0); // MethodResolutionKind.BadArguments
Diagnostic(ErrorCode.ERR_BadArgType, "2.0").WithArguments("2", "double", "int").WithLocation(43, 28), Diagnostic(ErrorCode.ERR_BadArgType, "2.0").WithArguments("2", "double", "int").WithLocation(43, 28),
// (44,17): error CS0411: The type arguments for method 'N1.N2.C.M4<T>(T, int)' cannot be inferred from the usage. Try specifying the type arguments explicitly. // (44,17): error CS0411: The type arguments for method 'N1.N2.C.M4<T>(T, int)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
// this.M4(null, 2); // MethodResolutionKind.TypeInferenceFailed // this.M4(null, 2); // MethodResolutionKind.TypeInferenceFailed
Diagnostic(ErrorCode.ERR_CantInferMethTypeArgs, "this.M4").WithArguments("N1.N2.C.M4<T>(T, int)").WithLocation(44, 17), Diagnostic(ErrorCode.ERR_CantInferMethTypeArgs, "M4").WithArguments("N1.N2.C.M4<T>(T, int)").WithLocation(44, 22),
// (45,47): error CS1503: Argument 3: cannot convert from 'int' to 'string' // (45,47): error CS1503: Argument 3: cannot convert from 'int' to 'string'
// this.M5<string, string>(null, 2); // Bad arity // this.M5<string, string>(null, 2); // Bad arity
Diagnostic(ErrorCode.ERR_BadArgType, "2").WithArguments("3", "int", "string").WithLocation(45, 47), Diagnostic(ErrorCode.ERR_BadArgType, "2").WithArguments("3", "int", "string").WithLocation(45, 47),
// (46,17): error CS0121: The call is ambiguous between the following methods or properties: 'N1.N2.C.M6(object, string)' and 'N1.N2.C.M6(string, object)' // (46,17): error CS0121: The call is ambiguous between the following methods or properties: 'N1.N2.C.M6(object, string)' and 'N1.N2.C.M6(string, object)'
// this.M6(null, null); // Ambiguous // this.M6(null, null); // Ambiguous
Diagnostic(ErrorCode.ERR_AmbigCall, "this.M6").WithArguments("N1.N2.C.M6(object, string)", "N1.N2.C.M6(string, object)").WithLocation(46, 17)); Diagnostic(ErrorCode.ERR_AmbigCall, "M6").WithArguments("N1.N2.C.M6(object, string)", "N1.N2.C.M6(string, object)").WithLocation(46, 22));
} }
/// <summary> /// <summary>
...@@ -736,7 +736,7 @@ static void M(object o) ...@@ -736,7 +736,7 @@ static void M(object o)
var compilation = CreateCompilationWithMscorlib(source, references: new[] { SystemCoreRef }); var compilation = CreateCompilationWithMscorlib(source, references: new[] { SystemCoreRef });
compilation.VerifyDiagnostics( compilation.VerifyDiagnostics(
// (22,17): error CS0121: The call is ambiguous between the following methods or properties: 'N1.N2.S.E(object, double, N1.A)' and 'N1.N2.S.E(object, double, N1.B)' // (22,17): error CS0121: The call is ambiguous between the following methods or properties: 'N1.N2.S.E(object, double, N1.A)' and 'N1.N2.S.E(object, double, N1.B)'
Diagnostic(ErrorCode.ERR_AmbigCall, "o.E").WithArguments("N1.N2.S.E(object, double, N1.A)", "N1.N2.S.E(object, double, N1.B)").WithLocation(22, 17), Diagnostic(ErrorCode.ERR_AmbigCall, "E").WithArguments("N1.N2.S.E(object, double, N1.A)", "N1.N2.S.E(object, double, N1.B)").WithLocation(22, 19),
// (23,26): error CS1503: Argument 3: cannot convert from 'double' to 'N1.A' // (23,26): error CS1503: Argument 3: cannot convert from 'double' to 'N1.A'
Diagnostic(ErrorCode.ERR_BadArgType, "2.0").WithArguments("3", "double", "N1.A").WithLocation(23, 26)); Diagnostic(ErrorCode.ERR_BadArgType, "2.0").WithArguments("3", "double", "N1.A").WithLocation(23, 26));
} }
...@@ -825,7 +825,7 @@ static class S ...@@ -825,7 +825,7 @@ static class S
var compilation = CreateCompilationWithMscorlib(source, references: new[] { SystemCoreRef }); var compilation = CreateCompilationWithMscorlib(source, references: new[] { SystemCoreRef });
compilation.VerifyDiagnostics( compilation.VerifyDiagnostics(
// (9, 9): error CS1593: Delegate 'System.Action<int>' does not take 2 arguments // (9, 9): error CS1593: Delegate 'System.Action<int>' does not take 2 arguments
Diagnostic(ErrorCode.ERR_BadDelArgCount, "this.F").WithArguments("System.Action<int>", "2").WithLocation(9, 9), Diagnostic(ErrorCode.ERR_BadDelArgCount, "F").WithArguments("System.Action<int>", "2").WithLocation(9, 14),
// (10,16): error CS1503: Argument 1: cannot convert from 'double' to 'int' // (10,16): error CS1503: Argument 1: cannot convert from 'double' to 'int'
Diagnostic(ErrorCode.ERR_BadArgType, "1.0").WithArguments("1", "double", "int").WithLocation(10, 16)); Diagnostic(ErrorCode.ERR_BadArgType, "1.0").WithArguments("1", "double", "int").WithLocation(10, 16));
} }
...@@ -1614,10 +1614,10 @@ static void M(string s) ...@@ -1614,10 +1614,10 @@ static void M(string s)
}"; }";
var compilation = CreateCompilationWithMscorlib(source, references: new[] { SystemCoreRef }); var compilation = CreateCompilationWithMscorlib(source, references: new[] { SystemCoreRef });
compilation.VerifyDiagnostics( compilation.VerifyDiagnostics(
Diagnostic(ErrorCode.ERR_AmbigCall, "s.E").WithArgumentsAnyOrder("A.E(string, int)", "B.E(string, int)").WithLocation(10, 9), Diagnostic(ErrorCode.ERR_AmbigCall, "E").WithArgumentsAnyOrder("A.E(string, int)", "B.E(string, int)").WithLocation(10, 11),
Diagnostic(ErrorCode.ERR_AmbigCall, "s.E").WithArgumentsAnyOrder("B.E(string, int)", "A.E(string, int)").WithLocation(17, 9), Diagnostic(ErrorCode.ERR_AmbigCall, "E").WithArgumentsAnyOrder("B.E(string, int)", "A.E(string, int)").WithLocation(17, 11),
Diagnostic(ErrorCode.ERR_AmbigCall, "s.E").WithArguments("N.S.A.E(string, int)", "N.S.B.E(string, int)").WithLocation(34, 13), Diagnostic(ErrorCode.ERR_AmbigCall, "E").WithArguments("N.S.A.E(string, int)", "N.S.B.E(string, int)").WithLocation(34, 15),
Diagnostic(ErrorCode.ERR_AmbigCall, "s.E").WithArguments("N.S.A.E(string, int)", "N.S.B.E(string, int)").WithLocation(41, 13)); Diagnostic(ErrorCode.ERR_AmbigCall, "E").WithArguments("N.S.A.E(string, int)", "N.S.B.E(string, int)").WithLocation(41, 15));
} }
/// <summary> /// <summary>
...@@ -1969,9 +1969,9 @@ static class S ...@@ -1969,9 +1969,9 @@ static class S
var compilation = CreateCompilationWithMscorlib(source, references: new[] { SystemCoreRef }); var compilation = CreateCompilationWithMscorlib(source, references: new[] { SystemCoreRef });
compilation.VerifyDiagnostics( compilation.VerifyDiagnostics(
// (6,9): error CS1928: 'int' does not contain a definition for 'E2' and the best extension method overload 'S.E2(double)' has some invalid arguments // (6,9): error CS1928: 'int' does not contain a definition for 'E2' and the best extension method overload 'S.E2(double)' has some invalid arguments
Diagnostic(ErrorCode.ERR_BadExtensionArgTypes, "2.E2").WithArguments("int", "E2", "S.E2(double)").WithLocation(6, 9), Diagnostic(ErrorCode.ERR_BadExtensionArgTypes, "E2").WithArguments("int", "E2", "S.E2(double)").WithLocation(6, 11),
// (7,9): error CS1928: 'int' does not contain a definition for 'E3' and the best extension method overload 'S.E3(long, params object[])' has some invalid arguments // (7,9): error CS1928: 'int' does not contain a definition for 'E3' and the best extension method overload 'S.E3(long, params object[])' has some invalid arguments
Diagnostic(ErrorCode.ERR_BadExtensionArgTypes, "3.E3").WithArguments("int", "E3", "S.E3(long, params object[])").WithLocation(7, 9)); Diagnostic(ErrorCode.ERR_BadExtensionArgTypes, "E3").WithArguments("int", "E3", "S.E3(long, params object[])").WithLocation(7, 11));
} }
[Fact] [Fact]
...@@ -2110,7 +2110,7 @@ static void M() ...@@ -2110,7 +2110,7 @@ static void M()
var compilation = CreateCompilationWithMscorlib(source, references: new[] { SystemCoreRef }); var compilation = CreateCompilationWithMscorlib(source, references: new[] { SystemCoreRef });
compilation.VerifyDiagnostics( compilation.VerifyDiagnostics(
// (37,13): error CS0121: The call is ambiguous between the following methods or properties: 'N1.S.E(object)' and 'N2.S.E(object)' // (37,13): error CS0121: The call is ambiguous between the following methods or properties: 'N1.S.E(object)' and 'N2.S.E(object)'
Diagnostic(ErrorCode.ERR_AmbigCall, "o.E").WithArguments("N1.S.E(object)", "N2.S.E(object)").WithLocation(37, 13)); Diagnostic(ErrorCode.ERR_AmbigCall, "E").WithArguments("N1.S.E(object)", "N2.S.E(object)").WithLocation(37, 15));
} }
[Fact] [Fact]
...@@ -2710,10 +2710,10 @@ static void M(this object x, object y) ...@@ -2710,10 +2710,10 @@ static void M(this object x, object y)
CreateCompilationWithMscorlibAndSystemCore(source).VerifyDiagnostics( CreateCompilationWithMscorlibAndSystemCore(source).VerifyDiagnostics(
// (5,9): error CS1501: No overload for method 'M' takes 2 arguments // (5,9): error CS1501: No overload for method 'M' takes 2 arguments
// x.M(x, y); // x.M(x, y);
Diagnostic(ErrorCode.ERR_BadArgCount, "x.M").WithArguments("M", "2").WithLocation(5, 9), Diagnostic(ErrorCode.ERR_BadArgCount, "M").WithArguments("M", "2").WithLocation(5, 11),
// (6,9): error CS7036: There is no argument given that corresponds to the required formal parameter 'y' of 'S.M(object, object)' // (6,9): error CS7036: There is no argument given that corresponds to the required formal parameter 'y' of 'S.M(object, object)'
// x.M(); // x.M();
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "x.M").WithArguments("y", "S.M(object, object)").WithLocation(6, 9), Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M").WithArguments("y", "S.M(object, object)").WithLocation(6, 11),
// (7,9): error CS7036: There is no argument given that corresponds to the required formal parameter 'y' of 'S.M(object, object)' // (7,9): error CS7036: There is no argument given that corresponds to the required formal parameter 'y' of 'S.M(object, object)'
// M(x); // M(x);
Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M").WithArguments("y", "S.M(object, object)").WithLocation(7, 9)); Diagnostic(ErrorCode.ERR_NoCorrespondingArgument, "M").WithArguments("y", "S.M(object, object)").WithLocation(7, 9));
...@@ -3265,7 +3265,7 @@ internal static class B ...@@ -3265,7 +3265,7 @@ internal static class B
var compilation = CreateCompilationWithMscorlibAndSystemCore(source); var compilation = CreateCompilationWithMscorlibAndSystemCore(source);
compilation.VerifyDiagnostics( compilation.VerifyDiagnostics(
// (16,13): error CS0121: The call is ambiguous between the following methods or properties: 'NA.A.F(object)' and 'NA.B.F(object)' // (16,13): error CS0121: The call is ambiguous between the following methods or properties: 'NA.A.F(object)' and 'NA.B.F(object)'
Diagnostic(ErrorCode.ERR_AmbigCall, "new object().F").WithArguments("NA.A.F(object)", "NA.B.F(object)").WithLocation(16, 13), Diagnostic(ErrorCode.ERR_AmbigCall, "F").WithArguments("NA.A.F(object)", "NA.B.F(object)").WithLocation(16, 26),
// (1,1): info CS8019: Unnecessary using directive. // (1,1): info CS8019: Unnecessary using directive.
// using NB; // using NB;
Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using NB;")); Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using NB;"));
......
...@@ -6433,7 +6433,7 @@ internal override void F<X>(X o) ...@@ -6433,7 +6433,7 @@ internal override void F<X>(X o)
}"; }";
CreateCompilationWithMscorlibAndSystemCore(source).VerifyDiagnostics( CreateCompilationWithMscorlibAndSystemCore(source).VerifyDiagnostics(
// (18,9): error CS1061: 'X' does not contain a definition for 'E1' and no extension method 'E1' accepting a first argument of type 'X' could be found (are you missing a using directive or an assembly reference?) // (18,9): error CS1061: 'X' does not contain a definition for 'E1' and no extension method 'E1' accepting a first argument of type 'X' could be found (are you missing a using directive or an assembly reference?)
Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "o.E1").WithArguments("X", "E1").WithLocation(18, 9)); Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "E1").WithArguments("X", "E1").WithLocation(18, 11));
} }
[Fact] [Fact]
......
...@@ -2057,7 +2057,7 @@ static void Main() ...@@ -2057,7 +2057,7 @@ static void Main()
CreateCompilationWithCustomILSource(source2, il).VerifyDiagnostics( CreateCompilationWithCustomILSource(source2, il).VerifyDiagnostics(
// (7,17): error CS7085: By-reference return type 'ref int' is not supported. // (7,17): error CS7085: By-reference return type 'ref int' is not supported.
// var x = i.M(); // var x = i.M();
Diagnostic(ErrorCode.ERR_ByRefReturnUnsupported, "i.M").WithArguments("int")); Diagnostic(ErrorCode.ERR_ByRefReturnUnsupported, "M").WithArguments("int"));
} }
[WorkItem(547149)] [WorkItem(547149)]
......
...@@ -439,9 +439,9 @@ void M(C c) ...@@ -439,9 +439,9 @@ void M(C c)
// (7,20): error CS0570: 'C.F2' is not supported by the language // (7,20): error CS0570: 'C.F2' is not supported by the language
Diagnostic(ErrorCode.ERR_BindToBogus, "F2").WithArguments("C.F2"), Diagnostic(ErrorCode.ERR_BindToBogus, "F2").WithArguments("C.F2"),
// (8,18): error CS0570: 'C.M1()' is not supported by the language // (8,18): error CS0570: 'C.M1()' is not supported by the language
Diagnostic(ErrorCode.ERR_BindToBogus, "c.M1").WithArguments("C.M1()"), Diagnostic(ErrorCode.ERR_BindToBogus, "M1").WithArguments("C.M1()"),
// (9,18): error CS0570: 'C.M2()' is not supported by the language // (9,18): error CS0570: 'C.M2()' is not supported by the language
Diagnostic(ErrorCode.ERR_BindToBogus, "c.M2").WithArguments("C.M2()"), Diagnostic(ErrorCode.ERR_BindToBogus, "M2").WithArguments("C.M2()"),
// (10,20): error CS0570: 'C.P1' is not supported by the language // (10,20): error CS0570: 'C.P1' is not supported by the language
Diagnostic(ErrorCode.ERR_BindToBogus, "P1").WithArguments("C.P1"), Diagnostic(ErrorCode.ERR_BindToBogus, "P1").WithArguments("C.P1"),
// (11,20): error CS0570: 'C.P2' is not supported by the language // (11,20): error CS0570: 'C.P2' is not supported by the language
......
...@@ -1261,9 +1261,9 @@ public static void Main() ...@@ -1261,9 +1261,9 @@ public static void Main()
c.VerifyDiagnostics( c.VerifyDiagnostics(
// (6,20): error CS0570: 'C.RT()' is not supported by the language // (6,20): error CS0570: 'C.RT()' is not supported by the language
Diagnostic(ErrorCode.ERR_BindToBogus, "C.RT").WithArguments("C.RT()"), Diagnostic(ErrorCode.ERR_BindToBogus, "RT").WithArguments("C.RT()"),
// (7,20): error CS0570: 'C.VT()' is not supported by the language // (7,20): error CS0570: 'C.VT()' is not supported by the language
Diagnostic(ErrorCode.ERR_BindToBogus, "C.VT").WithArguments("C.VT()")); Diagnostic(ErrorCode.ERR_BindToBogus, "VT").WithArguments("C.VT()"));
} }
[WorkItem(666162)] [WorkItem(666162)]
[Fact] [Fact]
......
...@@ -2393,7 +2393,7 @@ void Foo() ...@@ -2393,7 +2393,7 @@ void Foo()
CreateCompilationWithCustomILSource(csharp, il).VerifyDiagnostics( CreateCompilationWithCustomILSource(csharp, il).VerifyDiagnostics(
// (16,9): error CS0570: 'C.GAB(ref ?)' is not supported by the language // (16,9): error CS0570: 'C.GAB(ref ?)' is not supported by the language
// c.GAB(ref c); // c.GAB(ref c);
Diagnostic(ErrorCode.ERR_BindToBogus, "c.GAB").WithArguments("C.GAB(ref ?)")); Diagnostic(ErrorCode.ERR_BindToBogus, "GAB").WithArguments("C.GAB(ref ?)"));
} }
[WorkItem(545653)] [WorkItem(545653)]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册