public override bool Resolve (BlockContext ec)
{
expr = expr.Resolve (ec);
if (expr == null)
return false;
if (expr.IsNull) {
ec.Report.Error (186, loc, "Use of null is not valid in this context");
return false;
}
if (expr.Type == TypeManager.string_type) {
statement = new ArrayForeach (this, 1);
} else if (expr.Type is ArrayContainer) {
statement = new ArrayForeach (this, ((ArrayContainer) expr.Type).Rank);
} else {
if (expr.eclass == ExprClass.MethodGroup || expr is AnonymousMethodExpression) {
ec.Report.Error (446, expr.Location, "Foreach statement cannot operate on a `{0}'",
expr.ExprClassName);
return false;
}
statement = new CollectionForeach (type, variable, expr, statement, loc);
}
return statement.Resolve (ec);
}