[svn] r6122: nemerle/trunk/ncc: generation/ILEmitter.n testsuite/positive/generics2.n

nazgul svnadmin at nemerle.org
Sun Feb 12 19:49:24 CET 2006


Log:
Box before converting value type to 'a

Author: nazgul
Date: Sun Feb 12 19:49:16 2006
New Revision: 6122

Modified:
   nemerle/trunk/ncc/generation/ILEmitter.n
   nemerle/trunk/ncc/testsuite/positive/generics2.n

Modified: nemerle/trunk/ncc/generation/ILEmitter.n
==============================================================================
--- nemerle/trunk/ncc/generation/ILEmitter.n	(original)
+++ nemerle/trunk/ncc/generation/ILEmitter.n	Sun Feb 12 19:49:16 2006
@@ -708,6 +708,8 @@
 
         | TypeConversion (expr, cast_to_type, _) when cast_to_type.SystemType.IsGenericParameter =>
           emit (expr);
+          when (expr.Type.Fix().IsValueType)
+            _ilg.Emit (OpCodes.Box, expr.SystemType);
           _ilg.Emit (OpCodes.Unbox_Any, cast_to_type.SystemType);
           
         | TypeConversion (ignored, ty, _) when is_void (ty) =>

Modified: nemerle/trunk/ncc/testsuite/positive/generics2.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/generics2.n	(original)
+++ nemerle/trunk/ncc/testsuite/positive/generics2.n	Sun Feb 12 19:49:16 2006
@@ -49,6 +49,24 @@
     }
     
     
+module Bug605 {
+  public ReadField ['a] (_index : int) : 'a {
+      def ty = typeof ('a);
+      if (ty.Equals (typeof (int)))
+        1 :> 'a
+      else if (ty.Equals (typeof (long)))
+        1L :> 'a
+      else if (ty.Equals (typeof (byte)))
+        1b :> 'a
+      else if (ty.Equals (typeof (string)))
+        "aa" :> 'a
+      else
+        throw System.NotImplementedException (ty.ToString ())
+  }
+}
+
+        
+    
 class AunderB ['a, 'b] where 'a : 'b {
   public static x : AunderB ['a, 'b] = AunderB();
   
@@ -60,6 +78,11 @@
 AunderB.x.foo (1,1);
 AunderB.x.foo (A1(), A());
     
+_ = Bug605.ReadField (1) : int;
+_ = Bug605.ReadField (1) : long;
+_ = Bug605.ReadField (1) : byte;
+_ = Bug605.ReadField (1) : string;
+
     
 /*
 BEGIN-OUTPUT



More information about the svn mailing list