[mono/mono] cd21aebc: Always show error message when type resolver produces ambiguous type. Fixes #16115

"Marek Safar ([email protected])" <[email protected]> Wed, 13 Nov 2013 19:43:20 +0000
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <0000014252fd47e4-092b309a-a9a3-4fad-a72e-cd41fc06f4fa-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/46ccd3b4a834...cd21aebc7a34

   Commit: cd21aebc7a34ef57a4a86801fe37c6a2f51a7d19
   Author: Marek Safar <[email protected]> (marek-safar)
     Date: 2013-11-13 19:38:18 GMT
      URL: https://github.com/mono/mono/commit/cd21aebc7a34ef57a4a86801fe37c6a2f51a7d19

Always show error message when type resolver produces ambiguous type. Fixes #16115

Changed paths:
  M mcs/mcs/class.cs
Added paths:
  A mcs/errors/cs0104-3.cs

Added: mcs/errors/cs0104-3.cs
===================================================================
@@ -0,0 +1,33 @@
+// CS0104: `X' is an ambiguous reference between `A.X' and `B.X'
+// Line: 25
+
+namespace A
+{
+	class X { }
+}
+
+namespace B
+{
+	class X { }
+}
+
+namespace C
+{
+	using System;
+	using A;
+	using B;
+
+	class Test 
+	{
+		static void Main ()
+		{
+			Foo (delegate {
+				X x;
+			});
+		}
+		
+		static void Foo (Action a)
+		{
+		}
+	}
+}

Modified: mcs/mcs/class.cs
===================================================================
@@ -2404,7 +2404,13 @@ public override FullNamedExpression LookupNamespaceOrType (string name, int arit
 				if (t != null && (t.IsAccessible (this) || mode == LookupMode.IgnoreAccessibility))
 					e = new TypeExpression (t, Location.Null);
 				else {
+					var errors = Compiler.Report.Errors;
 					e = Parent.LookupNamespaceOrType (name, arity, mode, loc);
+
+					// TODO: LookupNamespaceOrType does more than just lookup. The result
+					// cannot be cached or the error reporting won't happen
+					if (errors != Compiler.Report.Errors)
+						return e;
 				}
 			}
 


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches