[svn] r5789: nemerle/trunk/ncc: generation/ILEmitter.n generation/Typer4.n hierarchy/MacroClassGen.n tests...

nazgul svnadmin at nemerle.org
Sun Oct 2 17:23:45 CEST 2005


Log:
Fix 'a to 'b conversions

Author: nazgul
Date: Sun Oct  2 17:23:27 2005
New Revision: 5789

Modified:
   nemerle/trunk/ncc/generation/ILEmitter.n
   nemerle/trunk/ncc/generation/Typer4.n
   nemerle/trunk/ncc/hierarchy/MacroClassGen.n
   nemerle/trunk/ncc/testsuite/positive/generics.n

Modified: nemerle/trunk/ncc/generation/ILEmitter.n
==============================================================================
--- nemerle/trunk/ncc/generation/ILEmitter.n	(original)
+++ nemerle/trunk/ncc/generation/ILEmitter.n	Sun Oct  2 17:23:27 2005
@@ -670,6 +670,13 @@
           when no_cast_needed (expr.SystemType, cast_to_type.SystemType) =>
           emit (expr)
 
+        // special case for  'a : 'b conversion
+        | TypeConversion (expr, cast_to_type, ConversionKind.Boxing) 
+          when cast_to_type.SystemType.IsGenericParameter =>
+          emit (expr);
+          _ilg.Emit (OpCodes.Box, expr.SystemType);
+          _ilg.Emit (OpCodes.Unbox_Any, cast_to_type.SystemType);
+
         | TypeConversion (expr, cast_to_type, _) when cast_to_type.SystemType.IsGenericParameter =>
           emit (expr);
           _ilg.Emit (OpCodes.Unbox_Any, cast_to_type.SystemType);

Modified: nemerle/trunk/ncc/generation/Typer4.n
==============================================================================
--- nemerle/trunk/ncc/generation/Typer4.n	(original)
+++ nemerle/trunk/ncc/generation/Typer4.n	Sun Oct  2 17:23:27 2005
@@ -109,9 +109,11 @@
     {
       def src = expr.Type.Fix ();
 
-      ((src.IsValueType || src is MType.Void || src is MType.TyVarRef) 
+      (src.IsValueType || src is MType.Void) 
        && (!target_type.IsValueType && !(target_type is MType.TyVarRef)
-       ))
+       ) ||
+       (src is MType.TyVarRef && !target_type.IsValueType)
+       
     }
     
 

Modified: nemerle/trunk/ncc/hierarchy/MacroClassGen.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/MacroClassGen.n	(original)
+++ nemerle/trunk/ncc/hierarchy/MacroClassGen.n	Sun Oct  2 17:23:27 2005
@@ -726,6 +726,7 @@
         });
       // for identity we can return much simpler function 
       if (is_identity != int.MaxValue)
+//        <[ Nemerle.Identity () ]>
         <[ fun (x) { x } ]>
       else { 
         def plen = positions.Length;

Modified: nemerle/trunk/ncc/testsuite/positive/generics.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/generics.n	(original)
+++ nemerle/trunk/ncc/testsuite/positive/generics.n	Sun Oct  2 17:23:27 2005
@@ -78,6 +78,7 @@
       _ = C();
       def d = D("a");
       assert (d.Val == "a");
+      assert (Ident.[int,object]().apply (1) :> int == 1);
    }
 }
 
@@ -128,6 +129,14 @@
     | Nil
 }
 
+
+class Ident ['a, 'b] where 'a : 'b {
+  public apply (x : 'a) : 'b {
+    x
+  }
+}
+
+
 /*
 BEGIN-OUTPUT
 System.Collections.Generic.List`1[System.Int32]



More information about the svn mailing list