protected virtual Expression DoResolveInitializer(ResolveContext rc)
{
if (in_transit)
{
field.Compiler.Report.Error(110, expr.Location,
"The evaluation of the constant value for `{0}' involves a circular definition",
GetSignatureForError());
expr = null;
}
else
{
in_transit = true;
expr = expr.Resolve(rc);
}
in_transit = false;
if (expr != null)
{
Constant c = expr as Constant;
if (c != null)
{
c = field.ConvertInitializer(rc, c);
}
if (c == null)
{
if (TypeSpec.IsReferenceType(field.MemberType))
{
Error_ConstantCanBeInitializedWithNullOnly(rc, field.MemberType, expr.Location, GetSignatureForError());
}
else if (!(expr is Constant))
{
Error_ExpressionMustBeConstant(rc, expr.Location, GetSignatureForError());
}
else
{
expr.Error_ValueCannotBeConverted(rc, field.MemberType, false);
}
}
expr = c;
}
if (expr == null)
{
expr = New.Constantify(field.MemberType, Location);
if (expr == null)
{
expr = Constant.CreateConstantFromValue(field.MemberType, null, Location);
}
expr = expr.Resolve(rc);
}
return(expr);
}