[svn] r6211: nemerle/trunk/ncc: hierarchy/TypeBuilder.n testsuite/positive/gen-overload.n

nazgul svnadmin at nemerle.org
Mon May 1 12:22:47 CEST 2006


Log:
Differentiate overloaded methods on number of generic parameters

Author: nazgul
Date: Mon May  1 12:22:44 2006
New Revision: 6211

Modified:
   nemerle/trunk/ncc/hierarchy/TypeBuilder.n
   nemerle/trunk/ncc/testsuite/positive/gen-overload.n

Modified: nemerle/trunk/ncc/hierarchy/TypeBuilder.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/TypeBuilder.n	(original)
+++ nemerle/trunk/ncc/hierarchy/TypeBuilder.n	Mon May  1 12:22:44 2006
@@ -1464,6 +1464,9 @@
           // we simply add this method to the existing list
           meth :: acc
 
+        | x :: xs when (x :> IMethod).GetHeader().typarms.Length != meth.GetHeader().typarms.Length =>
+          replace_method (x :: acc, meth, xs)
+          
         // process next member 
         | x :: xs =>
           def m = x :> IMethod;
@@ -1480,13 +1483,14 @@
             };
 
           def sig_matches =
-            if (meth.Attributes %&& NemerleAttributes.Override)
+            (if (meth.Attributes %&& NemerleAttributes.Override)
               sub_current.Equals (mem.GetMemType ())
             else
-              (sub_current :> MType.Fun).from.Equals ((mem.GetMemType () :> MType.Fun).from);
+              (sub_current :> MType.Fun).from.Equals ((mem.GetMemType () :> MType.Fun).from))
+            && m.GetParameters ().Length == par_amount;
             
           // if signature of existing method is the new one
-          if (sig_matches && m.GetParameters ().Length == par_amount)
+          if (sig_matches)
           {
             // check if new method does not hide or conflict with
             // existing methods in this and base type

Modified: nemerle/trunk/ncc/testsuite/positive/gen-overload.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/gen-overload.n	(original)
+++ nemerle/trunk/ncc/testsuite/positive/gen-overload.n	Mon May  1 12:22:44 2006
@@ -30,6 +30,11 @@
         assert (G[string].foo2 (24) == 24);
         assert (G2.foo1 (24) == 24);
         assert (G2.foo2 (24) == 24);
+        
+
+        _ = NS.Test().DoIt ();
+        _ = NS.Test.DoIt ();
+        _ = NS.A().DoIt ();
     }
 }
 }
@@ -56,6 +61,32 @@
     }
 }
 
+namespace NS
+{
+  public class Test
+  {
+    virtual public DoIt() : object
+    {
+      System.Console.WriteLine ("aa");
+      null;
+    }
+    
+    // Comment this method and error will go away
+    static public DoIt[T]() : T
+    {
+      System.Console.WriteLine ("bb");
+      Nemerle.Extensions.DefaultValue (T);
+    }
+  }
+  
+  public class A : Test {
+     public override DoIt () : object  {
+       System.Console.WriteLine ("cc");
+       null
+     }
+  }
+}
+
 
 // REFERENCE: gen-overload-lib.dll
 
@@ -65,5 +96,8 @@
 Kura.
 executing B.foo
 executing C.foo
+aa
+bb
+cc
 END-OUTPUT
 */



More information about the svn mailing list