2002-12-02 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Mon, 2 Dec 2002 02:49:17 +0000 (02:49 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Mon, 2 Dec 2002 02:49:17 +0000 (02:49 -0000)
* namespace.cs: avoid duplicated 'using xxx' being added to
using_clauses. This prevents mcs from issuing and 'ambiguous type' error
when we get more than one 'using' statement for the same namespace.
Report a CS0105 warning for it.

svn path=/trunk/mcs/; revision=9333

mcs/mcs/ChangeLog
mcs/mcs/namespace.cs

index 86bcf66a0f9e480f5307343796f13ab3667ae36b..4ffb8bd22f6e096463d941a381fcd7432b368a79 100755 (executable)
@@ -1,3 +1,10 @@
+2002-12-02  Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * namespace.cs: avoid duplicated 'using xxx' being added to
+       using_clauses. This prevents mcs from issuing and 'ambiguous type' error
+       when we get more than one 'using' statement for the same namespace.
+       Report a CS0105 warning for it.
+
 2002-11-30  Miguel de Icaza  <miguel@ximian.com>
 
        * cs-tokenizer.cs (consume_identifier): use read directly, instead
index a173b903620bcb73b4f6b50eb6553262899e17ed..ec3d4d277c50c9050e9d9ebc23aee40f0522c217 100755 (executable)
@@ -21,6 +21,7 @@ namespace Mono.CSharp {
                Namespace parent;
                string name;
                ArrayList using_clauses;
+               Hashtable using_namespaces;
                Hashtable aliases;
                public bool DeclarationFound = false;
 
@@ -94,8 +95,18 @@ namespace Mono.CSharp {
                        if (using_clauses == null)
                                using_clauses = new ArrayList ();
 
+                       if (using_namespaces == null)
+                               using_namespaces = new Hashtable ();
+
+                       if (using_namespaces.ContainsKey (ns)) {
+                               Report.Warning (105, loc, "The using directive for '" + ns +
+                                                         "' appeared previously in this namespace");
+                               return;
+                       }
+
                        UsingEntry ue = new UsingEntry (ns, loc);
                        using_clauses.Add (ue);
+                       using_namespaces.Add (ns, ns);
                }
 
                public ArrayList UsingTable {