Don't throw when loading expressions wrongly marked as constants. Fixes #4105
[mono.git] / mcs / mcs / constant.cs
index 638b3e55ba16ba0934906db7452306f4798141fc..beb9512e6e5a5b7e31e432333e0b5fd8ff16e7ca 100644 (file)
@@ -7,6 +7,7 @@
 //
 // Copyright 2001-2003 Ximian, Inc.
 // Copyright 2003-2008 Novell, Inc.
+// Copyright 2011 Xamarin Inc
 //
 
 using System;
@@ -78,6 +79,11 @@ namespace Mono.CSharp {
                        return c;
                }
 
+               public override bool ContainsEmitWithAwait ()
+               {
+                       return false;
+               }
+
                public virtual Constant ConvertImplicitly (TypeSpec type)
                {
                        if (this.type == type)
@@ -154,8 +160,11 @@ namespace Mono.CSharp {
                                        return new NullConstant (t, loc);
                        }
 
-                       throw new InternalErrorException ("Constant value `{0}' has unexpected underlying type `{1}'",
-                               v, TypeManager.CSharpName (t));
+#if STATIC
+                       throw new InternalErrorException ("Constant value `{0}' has unexpected underlying type `{1}'", v, t.GetSignatureForError ());
+#else
+                       return null;
+#endif
                }
 
                public override Expression CreateExpressionTree (ResolveContext ec)
@@ -269,7 +278,7 @@ namespace Mono.CSharp {
                                return this;
 
                        Constant c;
-                       if (TypeManager.IsEnumType (target_type)) {
+                       if (target_type.IsEnum) {
                                c = TryReduce (ec, EnumSpec.GetUnderlyingType (target_type));
                                if (c == null)
                                        return null;