Fix Firebird 'make dist' and build
[mono.git] / mcs / gmcs / expression.cs
index a43cba05bddc122274ec37e7b65e46b424fe6f86..1d35cb53fec2c5cc52974b9b5b05976b2347588c 100644 (file)
@@ -1231,7 +1231,7 @@ namespace Mono.CSharp {
                        eclass = ExprClass.Value;
                        Type etype = expr.Type;
 
-                       if (TypeManager.IsValueType (probe_type)){
+                       if (probe_type.IsValueType) {
                                Report.Error (77, loc, "The as operator must be used with a reference type (`" +
                                              TypeManager.CSharpName (probe_type) + "' is a value type)");
                                return null;
@@ -1349,7 +1349,7 @@ namespace Mono.CSharp {
                        if (expr.Type == target_type)
                                return expr;
 
-                       if (TypeManager.IsEnumType (target_type))
+                       if (TypeManager.IsEnumType (target_type) && TypeManager.EnumToUnderlying (target_type) == expr.Type)
                                return new EnumConstant ((Constant)expr, target_type);
 
                        Expression real_expr = expr;
@@ -3756,6 +3756,11 @@ namespace Mono.CSharp {
                                        return null;
                        }
                        
+                       Assign ass = expr as Assign;
+                       if (ass != null && ass.Source is Constant) {
+                               Report.Warning (665, 3, loc, "Assignment in conditional expression is always constant; did you mean to use == instead of = ?");
+                       }
+
                        trueExpr = trueExpr.Resolve (ec);
                        falseExpr = falseExpr.Resolve (ec);
 
@@ -3869,6 +3874,12 @@ namespace Mono.CSharp {
                        }
                }
 
+               public bool VerifyAssigned (EmitContext ec)
+               {
+                       VariableInfo variable_info = local_info.VariableInfo;
+                       return variable_info == null || variable_info.IsAssigned (ec, loc);
+               }
+
                protected Expression DoResolveBase (EmitContext ec, Expression lvalue_right_side)
                {
                        if (local_info == null) {
@@ -3906,7 +3917,7 @@ namespace Mono.CSharp {
                                return e.Resolve (ec);
                        }
 
-                       if ((variable_info != null) && !variable_info.IsAssigned (ec, loc))
+                       if (!VerifyAssigned (ec))
                                return null;
 
                        if (lvalue_right_side == null)
@@ -4998,7 +5009,7 @@ namespace Mono.CSharp {
                                if (a_mod == p_mod ||
                                    (a_mod == Parameter.Modifier.NONE && p_mod == Parameter.Modifier.PARAMS)) {
                                        if (a_mod == Parameter.Modifier.NONE) {
-                                                if (!Convert.ImplicitConversionExists (ec,
+                                                if (!TypeManager.IsEqual (a.Type, pd.ParameterType (i)) && !Convert.ImplicitConversionExists (ec,
                                                                                        a.Expr,
                                                                                        pd.ParameterType (i)))
                                                        return false;
@@ -5827,7 +5838,7 @@ namespace Mono.CSharp {
                                if (!omit_args) {
                                        Type t = null;
                                        if (this_call) {
-                                               ig.Emit (OpCodes.Ldarg_0);
+                                               ec.EmitThis ();
                                                t = decl_type;
                                        } else {
                                                Type iexpr_type = instance_expr.Type;
@@ -7707,15 +7718,22 @@ namespace Mono.CSharp {
                                return mg.ResolveGeneric (ec, args);
                        }
 
+                       if (original != null && !TypeManager.IsValueType (expr_type)) {
+                               me = member_lookup as MemberExpr;
+                               if (me != null && me.IsInstance) {
+                                       LocalVariableReference var = new_expr as LocalVariableReference;
+                                       if (var != null && !var.VerifyAssigned (ec))
+                                               return null;
+                               }
+                       }
+
                        // The following DoResolve/DoResolveLValue will do the definite assignment
                        // check.
 
                        if (right_side != null)
-                               member_lookup = member_lookup.DoResolveLValue (ec, right_side);
+                               return member_lookup.DoResolveLValue (ec, right_side);
                        else
-                               member_lookup = member_lookup.DoResolve (ec);
-
-                       return member_lookup;
+                               return member_lookup.DoResolve (ec);
                }
 
                public override Expression DoResolve (EmitContext ec)