Author: marek
Date: 2007-11-07 04:07:10 -0500 (Wed, 07 Nov 2007)
New Revision: 89075
Modified:
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/convert.cs
Log:
2007-11-07 Marek Safar <[EMAIL PROTECTED]>
A fix for bug #320236
* convert.cs: Don't apply user conversion on underlying target type.
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2007-11-07 09:07:08 UTC (rev 89074)
+++ trunk/mcs/mcs/ChangeLog 2007-11-07 09:07:10 UTC (rev 89075)
@@ -1,3 +1,8 @@
+2007-11-07 Marek Safar <[EMAIL PROTECTED]>
+
+ A fix for bug #320236
+ * convert.cs: Don't apply user conversion on underlying target type.
+
2007-11-06 Marek Safar <[EMAIL PROTECTED]>
* expression.cs: Don't use unresolved expression for error reporting.
Modified: trunk/mcs/mcs/convert.cs
===================================================================
--- trunk/mcs/mcs/convert.cs 2007-11-07 09:07:08 UTC (rev 89074)
+++ trunk/mcs/mcs/convert.cs 2007-11-07 09:07:10 UTC (rev 89075)
@@ -1950,10 +1950,12 @@
return new UnboxCast (expr, target_type);
if (TypeManager.IsEnumType (expr_type)) {
- if (expr is EnumConstant)
- return ExplicitConversionCore (ec,
((EnumConstant) expr).Child, target_type, loc);
+ Expression underlying = EmptyCast.Create (expr,
TypeManager.EnumToUnderlying (expr_type));
+ expr = ExplicitConversionCore (ec, underlying,
target_type, loc);
+ if (expr != null)
+ return expr;
- return ExplicitConversionCore (ec,
EmptyCast.Create (expr, TypeManager.EnumToUnderlying (expr_type)), target_type,
loc);
+ return ExplicitUserConversion (ec, underlying,
target_type, loc);
}
if (TypeManager.IsEnumType (target_type)){
@@ -1985,11 +1987,7 @@
if (ne != null)
return ne;
}
-
- ne = ExplicitUserConversion (ec, expr, target_type,
loc);
- if (ne != null)
- return ne;
-
+
return null;
}
@@ -2093,15 +2091,17 @@
} else if (TypeManager.IsNullableType (expr_type)) {
Expression source = Nullable.Unwrap.Create
(expr, ec);
if (source != null) {
- e = ExplicitConversionCore (ec, source,
target_type, loc);
- if (e != null)
- return e;
+ return ExplicitConversion (ec, source,
target_type, loc);
}
}
#endif
e = ExplicitConversionCore (ec, expr, target_type, loc);
if (e != null)
return e;
+
+ e = ExplicitUserConversion (ec, expr, target_type, loc);
+ if (e != null)
+ return e;
expr.Error_ValueCannotBeConverted (ec, loc,
target_type, true);
return null;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches