X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Fecore.cs;h=46a3c677a1a5e01ad9ecd576180fd6d508ca82b8;hb=c5118cc145a60dccbb8247b9f4917d286056b54e;hp=ee129c5c702208b7089309425330b76fc7417e78;hpb=147ded2fb63d2575a941a25582a177ed9cccd1a6;p=mono.git diff --git a/mcs/mcs/ecore.cs b/mcs/mcs/ecore.cs index ee129c5c702..46a3c677a1a 100755 --- a/mcs/mcs/ecore.cs +++ b/mcs/mcs/ecore.cs @@ -336,7 +336,7 @@ namespace Mono.CSharp { if ((e is TypeExpr) || (e is ComposedCast)) { if ((flags & ResolveFlags.Type) == 0) { - e.Error118 (flags); + e.Error_UnexpectedKind (flags); return null; } @@ -346,7 +346,7 @@ namespace Mono.CSharp { switch (e.eclass) { case ExprClass.Type: if ((flags & ResolveFlags.VariableOrValue) == 0) { - e.Error118 (flags); + e.Error_UnexpectedKind (flags); return null; } break; @@ -369,7 +369,7 @@ namespace Mono.CSharp { FieldInfo fi = ((FieldExpr) e).FieldInfo; Console.WriteLine ("{0} and {1}", fi.DeclaringType, fi.Name); - e.Error118 (flags); + e.Error_UnexpectedKind (flags); return null; } break; @@ -729,7 +729,7 @@ namespace Mono.CSharp { // 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) { + if (target_type == TypeManager.object_type) { // // A pointer type cannot be converted to object // @@ -740,6 +740,11 @@ namespace Mono.CSharp { return new BoxedCast (expr); if (expr_type.IsClass || expr_type.IsInterface || expr_type == TypeManager.enum_type) return new EmptyCast (expr, target_type); + } else if (target_type == TypeManager.value_type) { + if (expr_type.IsValueType) + return new BoxedCast (expr); + if (expr is NullLiteral) + return new BoxedCast (expr); } else if (expr_type.IsSubclassOf (target_type)) { // // Special case: enumeration to System.Enum. @@ -2467,7 +2472,7 @@ namespace Mono.CSharp { /// /// Reports that we were expecting `expr' to be of class `expected' /// - public void Error118 (string expected) + public void Error_UnexpectedKind (string expected) { string kind = "Unknown"; @@ -2477,7 +2482,7 @@ namespace Mono.CSharp { "' where a `" + expected + "' was expected"); } - public void Error118 (ResolveFlags flags) + public void Error_UnexpectedKind (ResolveFlags flags) { ArrayList valid = new ArrayList (10);