2005-03-23 Lluis Sanchez Gual <lluis@novell.com>
[mono.git] / mcs / bmcs / assign.cs
index 6c5c87d56eaf29f739501bbd4e7ddb50550d745c..ef55d17fefb504fd3c92b9b4b8a44daf1968fcdb 100644 (file)
@@ -388,7 +388,7 @@ namespace Mono.CSharp {
                        }
 
                        FieldExpr field_exp = target as FieldExpr;
-                       if (field_exp != null && !ec.IsConstructor && !ec.IsFieldInitializer) {
+                       if (field_exp != null && field_exp.DeclaringType.IsValueType && !ec.IsConstructor && !ec.IsFieldInitializer) {
                                field_exp = field_exp.InstanceExpression as FieldExpr;
                                if (field_exp != null && field_exp.FieldInfo.IsInitOnly) {
                                        if (field_exp.IsStatic) {
@@ -449,9 +449,9 @@ namespace Mono.CSharp {
                                        //    target_type
                                        //
                                        
-                                       source = Convert.ExplicitConversion (ec, source, target_type, loc);
+                                       source = Convert.WideningAndNarrowingConversion (ec, source, target_type, loc);
                                        if (source == null){
-                                               Convert.Error_CannotImplicitConversion (loc, source_type, target_type);
+                                               Convert.Error_CannotWideningConversion (loc, source_type, target_type);
                                                return null;
                                        }
                                
@@ -459,7 +459,7 @@ namespace Mono.CSharp {
                                        // 2. and the original right side is implicitly convertible to
                                        // the type of target
                                        //
-                                       if (Convert.ImplicitStandardConversionExists (ec, a.original_source, target_type))
+                                       if (Convert.WideningStandardConversionExists (ec, a.original_source, target_type))
                                                return this;
 
                                        //
@@ -470,12 +470,12 @@ namespace Mono.CSharp {
                                            (b.Oper == Binary.Operator.LeftShift || b.Oper == Binary.Operator.RightShift))
                                                return this;
 
-                                       Convert.Error_CannotImplicitConversion (loc, a.original_source.Type, target_type);
+                                       Convert.Error_CannotWideningConversion (loc, a.original_source.Type, target_type);
                                        return null;
                                }
                        }
 
-                       source = Convert.ImplicitConversionRequired (ec, source, target_type, loc);
+                       source = Convert.WideningConversionRequired (ec, source, target_type, loc);
                        if (source == null)
                                return null;