Merge pull request #495 from nicolas-raoul/fix-for-issue2907-with-no-formatting-changes
[mono.git] / mcs / class / corlib / System.Reflection.Emit / ParameterBuilder.cs
index a81048c38583cdd7169f35497b59fb3686132933..97f998051304136cc366fea080def4168c65dd44 100644 (file)
@@ -32,6 +32,7 @@
 // (C) 2001 Ximian, Inc.  http://www.ximian.com
 //
 
+#if !FULL_AOT_RUNTIME
 using System;
 using System.Reflection;
 using System.Reflection.Emit;
@@ -95,8 +96,10 @@ namespace System.Reflection.Emit {
                {
                        if (position > 0) {
                                Type t = methodb.GetParameterType (position - 1);
-                               if (defaultValue != null && t != defaultValue.GetType ())
-                                       throw new ArgumentException ("Constant does not match the defined type.");
+                               if (defaultValue != null && t != defaultValue.GetType ()) {
+                                       if(!t.IsEnum || t.UnderlyingSystemType != defaultValue.GetType ())
+                                               throw new ArgumentException ("Constant does not match the defined type.");
+                               }
                                if (t.IsValueType && !t.IsPrimitive && !t.IsEnum && t != typeof (DateTime))
                                        throw new ArgumentException ("" + t + " is not a supported constant type.");
                        }
@@ -173,3 +176,4 @@ namespace System.Reflection.Emit {
        }
 }
 
+#endif