|
|
@@ -415,24 +415,24 @@ namespace Mono.CSharp {
|
|
|
public Constant ResolveAsConstant (EmitContext ec, MemberCore mc)
|
|
|
{
|
|
|
Expression e = Resolve (ec);
|
|
|
- if (e != null) {
|
|
|
- Constant c = e as Constant;
|
|
|
- if (c != null)
|
|
|
- return c;
|
|
|
+ if (e == null)
|
|
|
+ return null;
|
|
|
|
|
|
- EmptyCast empty = e as EmptyCast;
|
|
|
- if (empty != null) {
|
|
|
- c = empty.Child as Constant;
|
|
|
- if (c != null) {
|
|
|
- // TODO: not sure about this maybe there is easier way how to use EmptyCast
|
|
|
- if (e.Type.IsEnum)
|
|
|
- c.Type = e.Type;
|
|
|
+ Constant c = e as Constant;
|
|
|
+ if (c != null)
|
|
|
+ return c;
|
|
|
|
|
|
- return c;
|
|
|
- }
|
|
|
+ EmptyCast empty = e as EmptyCast;
|
|
|
+ if (empty != null) {
|
|
|
+ c = empty.Child as Constant;
|
|
|
+ if (c != null) {
|
|
|
+ // TODO: not sure about this maybe there is easier way how to use EmptyCast
|
|
|
+ if (e.Type.IsEnum)
|
|
|
+ c.Type = e.Type;
|
|
|
+
|
|
|
+ return c;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
Const.Error_ExpressionMustBeConstant (loc, mc.GetSignatureForError ());
|
|
|
return null;
|
|
|
}
|
|
|
@@ -2161,7 +2161,7 @@ namespace Mono.CSharp {
|
|
|
if (!me.IsStatic &&
|
|
|
(!intermediate || !IdenticalNameAndTypeName (ec, me, loc))) {
|
|
|
Error_ObjectRefRequired (ec, loc, me.GetSignatureForError ());
|
|
|
- return null;
|
|
|
+ return EmptyExpression.Null;
|
|
|
}
|
|
|
|
|
|
//
|
|
|
@@ -3029,8 +3029,10 @@ namespace Mono.CSharp {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- if (ic.ResolveValue ())
|
|
|
- ic.CheckObsoleteness (loc);
|
|
|
+ if (ic.ResolveValue ()) {
|
|
|
+ if (ec.TestObsoleteMethodUsage)
|
|
|
+ ic.CheckObsoleteness (loc);
|
|
|
+ }
|
|
|
|
|
|
return ic.Value;
|
|
|
}
|
|
|
@@ -3087,7 +3089,8 @@ namespace Mono.CSharp {
|
|
|
ObsoleteAttribute oa;
|
|
|
FieldBase f = TypeManager.GetField (FieldInfo);
|
|
|
if (f != null) {
|
|
|
- f.CheckObsoleteness (loc);
|
|
|
+ if (ec.TestObsoleteMethodUsage)
|
|
|
+ f.CheckObsoleteness (loc);
|
|
|
// To be sure that type is external because we do not register generated fields
|
|
|
} else if (!(FieldInfo.DeclaringType is TypeBuilder)) {
|
|
|
oa = AttributeTester.GetMemberObsoleteAttribute (FieldInfo);
|