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.
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
//
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