Better error reporting for async delegates
[mono.git] / mcs / mcs / namespace.cs
index 7afb8f12158f6fac3ecd400061ea8115837e46be..bd55dce6c2bf3c9b00b200c600f6eb9cb884001d 100644 (file)
@@ -288,9 +288,6 @@ namespace Mono.CSharp {
                        if (best == null)
                                return null;
 
-//                     if ((best.Modifiers & Modifiers.INTERNAL) != 0 && !best.MemberDefinition.IsInternalAsPublic (ctx.Module.DeclaringAssembly))
-//                             return null;
-
                        te = new TypeExpression (best, Location.Null);
 
                        // TODO MemberCache: Cache more
@@ -373,9 +370,9 @@ namespace Mono.CSharp {
                        return res;
                }
 
-               /// 
-               /// Looks for extension method in this namespace
-               //
+               // 
+               // Looks for extension method in this namespace
+               //
                public List<MethodSpec> LookupExtensionMethod (IMemberContext invocationContext, TypeSpec extensionType, string name, int arity)
                {
                        if (types == null)
@@ -405,6 +402,26 @@ namespace Mono.CSharp {
                        return found;
                }
 
+               //
+               // Extension methods look up for dotted namespace names
+               //
+               public IList<MethodSpec> LookupExtensionMethod (IMemberContext invocationContext, TypeSpec extensionType, string name, int arity, out Namespace scope)
+               {
+                       //
+                       // Inspect parent namespaces in namespace expression
+                       //
+                       scope = this;
+                       do {
+                               var candidates = scope.LookupExtensionMethod (invocationContext, extensionType, name, arity);
+                               if (candidates != null)
+                                       return candidates;
+
+                               scope = scope.Parent;
+                       } while (scope != null);
+
+                       return null;
+               }
+
                public void AddType (ModuleContainer module, TypeSpec ts)
                {
                        if (types == null) {
@@ -800,7 +817,7 @@ namespace Mono.CSharp {
                // 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 IList<MethodSpec> LookupExtensionMethod (TypeSpec extensionType, string name, int arity, ref NamespaceContainer scope)
+               public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
                {
                        List<MethodSpec> candidates = null;
                        foreach (Namespace n in GetUsingTable ()) {
@@ -814,29 +831,21 @@ namespace Mono.CSharp {
                                        candidates.AddRange (a);
                        }
 
-                       scope = parent;
                        if (candidates != null)
-                               return candidates;
+                               return new ExtensionMethodCandidates (candidates, this);
 
                        if (parent == null)
                                return null;
 
-                       //
-                       // Inspect parent namespaces in namespace expression
-                       //
-                       Namespace parent_ns = ns.Parent;
-                       do {
-                               candidates = parent_ns.LookupExtensionMethod (this, extensionType, name, arity);
-                               if (candidates != null)
-                                       return candidates;
-
-                               parent_ns = parent_ns.Parent;
-                       } while (parent_ns != null);
+                       Namespace ns_scope;
+                       var ns_candidates = ns.Parent.LookupExtensionMethod (this, extensionType, name, arity, out ns_scope);
+                       if (ns_candidates != null)
+                               return new ExtensionMethodCandidates (ns_candidates, this, ns_scope);
 
                        //
-                       // Continue in parent scope
+                       // Continue in parent container
                        //
-                       return parent.LookupExtensionMethod (extensionType, name, arity, ref scope);
+                       return parent.LookupExtensionMethod (extensionType, name, arity);
                }
 
                public FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
@@ -1106,11 +1115,6 @@ namespace Mono.CSharp {
                        get { return SlaveDeclSpace.CurrentTypeParameters; }
                }
 
-               // FIXME: It's false for expression types
-               public bool HasUnresolvedConstraints {
-                       get { return true; }
-               }
-
                public bool IsObsolete {
                        get { return SlaveDeclSpace.IsObsolete; }
                }