throw new NotImplementedException ();
}
- public Compiler.ExtensionMethodCandidates LookupExtensionMethod (Compiler.TypeSpec extensionType, string name, int arity)
+ public Compiler.ExtensionMethodCandidates LookupExtensionMethod (string name, int arity)
{
// No extension method lookup in this context
return null;
--- /dev/null
+// CS1061: Type `int' does not contain a definition for `Foo' and no extension method `Foo' of type `int' could be found. Are you missing an assembly reference?
+// Line: 11
+
+using System;
+
+static class C
+{
+ static void Main ()
+ {
+ int i = 1;
+ Action a = i.Foo;
+ }
+
+ static void Foo (this string s)
+ {
+ }
+}
\ No newline at end of file
+++ /dev/null
-// CS1928: Type `System.Collections.IList' does not contain a member `Frobnicate' and the best extension method overload `Extensions.Frobnicate<Test>(this Test)' has some invalid arguments
-// Line: 20
-
-using System;
-using System.Collections;
-
-static class Extensions
-{
- public static void Frobnicate<T> (this T foo) where T : IList
- {
- }
-}
-
-public class Test
-{
- IList mFoo;
-
- void Frobnicate ()
- {
- mFoo.Frobnicate<Test> ();
- }
-}
+++ /dev/null
-// CS1928: Type `int' does not contain a member `Foo' and the best extension method overload `S.Foo(this uint)' has some invalid arguments
-// Line: 15
-
-static class S
-{
- public static void Foo (this uint i)
- {
- }
-}
-
-class B
-{
- static void Main ()
- {
- 55.Foo ();
- }
-}
--- /dev/null
+// CS1929: Type `System.Collections.IList' does not contain a member `Frobnicate' and the best extension method overload `Extensions.Frobnicate<Test>(this Test)' requires an instance of type `Test'
+// Line: 20
+
+using System;
+using System.Collections;
+
+static class Extensions
+{
+ public static void Frobnicate<T> (this T foo) where T : IList
+ {
+ }
+}
+
+public class Test
+{
+ IList mFoo;
+
+ void Frobnicate ()
+ {
+ mFoo.Frobnicate<Test> ();
+ }
+}
--- /dev/null
+// CS1929: Type `int' does not contain a member `Foo' and the best extension method overload `S.Foo(this uint)' requires an instance of type `uint'
+// Line: 15
+
+static class S
+{
+ public static void Foo (this uint i)
+ {
+ }
+}
+
+class B
+{
+ static void Main ()
+ {
+ 55.Foo ();
+ }
+}
-// CS1929: Extension method instance type `int' cannot be converted to `string'
+// CS1929: Type `int' does not contain a member `Check' and the best extension method overload `C.Check(this string)' requires an instance of type `string'
// Line: 12
static class C
return tc.GetSignatureForError ();
}
- public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
+ public ExtensionMethodCandidates LookupExtensionMethod (string name, int arity)
{
return null;
}
string GetSignatureForError ();
- ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity);
+ ExtensionMethodCandidates LookupExtensionMethod (string name, int arity);
FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc);
FullNamedExpression LookupNamespaceAlias (string name);
}
return MemberContext.GetSignatureForError ();
}
- public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
+ public ExtensionMethodCandidates LookupExtensionMethod (string name, int arity)
{
- return MemberContext.LookupExtensionMethod (extensionType, name, arity);
+ return MemberContext.LookupExtensionMethod (name, arity);
}
public FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
// Does extension methods look up to find a method which matches name and extensionType.
// Search starts from this namespace and continues hierarchically up to top level.
//
- public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
+ public ExtensionMethodCandidates LookupExtensionMethod (string name, int arity)
{
var m = Parent;
do {
var ns = m as NamespaceContainer;
if (ns != null)
- return ns.LookupExtensionMethod (this, extensionType, name, arity, 0);
+ return ns.LookupExtensionMethod (this, name, arity, 0);
m = m.Parent;
} while (m != null);
return host.GetSignatureForError ();
}
- public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
+ public ExtensionMethodCandidates LookupExtensionMethod (string name, int arity)
{
return null;
}
int arity = type_arguments == null ? 0 : type_arguments.Count;
- candidates = candidates.Container.LookupExtensionMethod (candidates.Context, ExtensionExpression.Type, Name, arity, candidates.LookupIndex);
+ candidates = candidates.Container.LookupExtensionMethod (candidates.Context, Name, arity, candidates.LookupIndex);
if (candidates == null)
return null;
bool OverloadResolver.IErrorHandler.ArgumentMismatch (ResolveContext rc, MemberSpec best, Argument arg, int index)
{
rc.Report.SymbolRelatedToPreviousError (best);
- rc.Report.Error (1928, loc,
- "Type `{0}' does not contain a member `{1}' and the best extension method overload `{2}' has some invalid arguments",
- queried_type.GetSignatureForError (), Name, best.GetSignatureForError ());
if (index == 0) {
rc.Report.Error (1929, loc,
- "Extension method instance type `{0}' cannot be converted to `{1}'",
- arg.Type.GetSignatureForError (), ((MethodSpec)best).Parameters.ExtensionMethodType.GetSignatureForError ());
+ "Type `{0}' does not contain a member `{1}' and the best extension method overload `{2}' requires an instance of type `{3}'",
+ queried_type.GetSignatureForError (), Name, best.GetSignatureForError (), ((MethodSpec)best).Parameters.ExtensionMethodType.GetSignatureForError ());
+ } else {
+ rc.Report.Error (1928, loc,
+ "Type `{0}' does not contain a member `{1}' and the best extension method overload `{2}' has some invalid arguments",
+ queried_type.GetSignatureForError (), Name, best.GetSignatureForError ());
}
return true;
return null;
int arity = type_arguments == null ? 0 : type_arguments.Count;
- var methods = rc.LookupExtensionMethod (InstanceExpression.Type, Methods[0].Name, arity);
+ var methods = rc.LookupExtensionMethod (Methods[0].Name, arity);
if (methods == null)
return null;
continue;
if ((restrictions & Restrictions.CovariantDelegate) != 0 && !Delegate.IsTypeCovariant (ec, a.Expr.Type, pt)) {
- custom_errors.NoArgumentMatch (ec, member);
+ if (a.IsExtensionType) {
+ // TODO: Should report better message type, something similar to CS1928/1929 instead of
+ // CS1061 but that still better than confusing CS0123
+ var ma = new MemberAccess (a.Expr, member.Name, loc);
+ ma.Error_TypeDoesNotContainDefinition (ec, a.Expr.Type, ma.Name);
+ } else {
+ custom_errors.NoArgumentMatch (ec, member);
+ }
return false;
}
// Try to look for extension method when member lookup failed
//
if (MethodGroupExpr.IsExtensionMethodArgument (expr)) {
- var methods = rc.LookupExtensionMethod (expr_type, Name, lookup_arity);
+ var methods = rc.LookupExtensionMethod (Name, lookup_arity);
if (methods != null) {
var emg = new ExtensionMethodGroupExpr (methods, expr, loc);
if (HasTypeArguments) {
base.EmitContainer ();
}
- public ExtensionMethodCandidates LookupExtensionMethod (IMemberContext invocationContext, TypeSpec extensionType, string name, int arity, int position)
+ public ExtensionMethodCandidates LookupExtensionMethod (IMemberContext invocationContext, string name, int arity, int position)
{
//
// Here we try to resume the search for extension method at the point
throw new NotImplementedException ();
}
- public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
+ public ExtensionMethodCandidates LookupExtensionMethod (string name, int arity)
{
return null;
}
throw new NotImplementedException ();
}
- public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
+ public ExtensionMethodCandidates LookupExtensionMethod (string name, int arity)
{
throw new NotImplementedException ();
}