2002-09-25 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Wed, 25 Sep 2002 21:41:33 +0000 (21:41 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Wed, 25 Sep 2002 21:41:33 +0000 (21:41 -0000)
* ecore.cs (ImplicitReferenceConversion): treat
TypeManager.value_type as a target just like object_type.   As
code like this:

ValueType v = 1;

Is valid, and needs to result in the int 1 being boxed before it
is assigned to the value type v.

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

mcs/mcs/ChangeLog
mcs/mcs/ecore.cs

index 23d9033566dda0a21dedc5be4fdb7f6165d5d0cb..fcd2520c4eacaea2a4e61c65f8b7a554554a5325 100755 (executable)
@@ -1,5 +1,14 @@
 2002-09-25  Miguel de Icaza  <miguel@ximian.com>
 
+       * ecore.cs (ImplicitReferenceConversion): treat
+       TypeManager.value_type as a target just like object_type.   As
+       code like this:
+
+       ValueType v = 1;
+
+       Is valid, and needs to result in the int 1 being boxed before it
+       is assigned to the value type v.
+
        * class.cs (TypeContainer.AddEnum): Use the basename, not the name
        to validate the enumeration name.
 
index 03cfe1165151869d951ce06818dd162e71228446..1cbd1ad96e1e6700bebe907b3a2aec93d9533692 100755 (executable)
@@ -668,8 +668,12 @@ namespace Mono.CSharp {
 
                                expr.Emit (null);
                        }
-                       
-                       if (target_type == TypeManager.object_type) {
+
+                       //
+                       // notice that it is possible to write "ValueType v = 1", the ValueType here
+                       // is an abstract class, and not really a value type, so we apply the same rules.
+                       //
+                       if (target_type == TypeManager.object_type || target_type == TypeManager.value_type) {
                                //
                                // A pointer type cannot be converted to object
                                // 
@@ -680,9 +684,9 @@ namespace Mono.CSharp {
                                        return new BoxedCast (expr);
                                if (expr_type.IsClass || expr_type.IsInterface)
                                        return new EmptyCast (expr, target_type);
-                       } else if (expr_type.IsSubclassOf (target_type)) {
+                       } else if (expr_type.IsSubclassOf (target_type)) 
                                return new EmptyCast (expr, target_type);
-                       else {
+                       else {
 
                                // This code is kind of mirrored inside StandardConversionExists
                                // with the small distinction that we only probe there