if ((e is TypeExpr) || (e is ComposedCast)) {
if ((flags & ResolveFlags.Type) == 0) {
- e.Error118 (flags);
+ e.Error_UnexpectedKind (flags);
return null;
}
switch (e.eclass) {
case ExprClass.Type:
if ((flags & ResolveFlags.VariableOrValue) == 0) {
- e.Error118 (flags);
+ e.Error_UnexpectedKind (flags);
return null;
}
break;
FieldInfo fi = ((FieldExpr) e).FieldInfo;
Console.WriteLine ("{0} and {1}", fi.DeclaringType, fi.Name);
- e.Error118 (flags);
+ e.Error_UnexpectedKind (flags);
return null;
}
break;
// 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
//
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.
/// <summary>
/// Reports that we were expecting `expr' to be of class `expected'
/// </summary>
- public void Error118 (string expected)
+ public void Error_UnexpectedKind (string expected)
{
string kind = "Unknown";
"' where a `" + expected + "' was expected");
}
- public void Error118 (ResolveFlags flags)
+ public void Error_UnexpectedKind (ResolveFlags flags)
{
ArrayList valid = new ArrayList (10);