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;
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;
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);
}
}
+ 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) {
return e.Resolve (ec);
}
- if ((variable_info != null) && !variable_info.IsAssigned (ec, loc))
+ if (!VerifyAssigned (ec))
return null;
if (lvalue_right_side == null)
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;
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;
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)