Don't resolve partial method default parameters twice
authorMarek Safar <marek.safar@gmail.com>
Thu, 1 Mar 2012 12:23:22 +0000 (12:23 +0000)
committerMarek Safar <marek.safar@gmail.com>
Thu, 1 Mar 2012 12:44:22 +0000 (12:44 +0000)
mcs/mcs/class.cs
mcs/tests/gtest-optional-21.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_5.xml

index 6a66670658fbcc0450f2db1af48dff1b33be8b89..f4f7181a47874eec7d0217807a120af69f747023 100644 (file)
@@ -256,7 +256,14 @@ namespace Mono.CSharp
                {
                        if (containers != null) {
                                foreach (var t in containers) {
-                                       t.PrepareEmit ();
+                                       try {
+                                               t.PrepareEmit ();
+                                       } catch (Exception e) {
+                                               if (MemberName == MemberName.Null)
+                                                       throw;
+
+                                               throw new InternalErrorException (t, e);
+                                       }
                                }
                        }
                }
@@ -1492,6 +1499,9 @@ namespace Mono.CSharp
 
                public override void PrepareEmit ()
                {
+                       if ((caching_flags & Flags.CloseTypeCreated) != 0)
+                               return;
+
                        foreach (var member in members) {
                                var pm = member as IParametersMember;
                                if (pm != null) {
diff --git a/mcs/tests/gtest-optional-21.cs b/mcs/tests/gtest-optional-21.cs
new file mode 100644 (file)
index 0000000..a305aa9
--- /dev/null
@@ -0,0 +1,19 @@
+using System.Runtime.InteropServices;
+
+partial class C
+{
+       public static void Foo (C c, [Optional] C c2)
+       {
+       }
+}
+
+partial class C
+{
+       public static void Foo2 ([Optional] C c2)
+       {
+       }
+
+       public static void Main ()
+       {
+       }
+}
\ No newline at end of file
index 18f91c38dfaa1fdcd6df877d95781a610ea86aa5..24adad5f115fa8d82ffd3dd26d829395aae0eef5 100644 (file)
       </method>
     </type>
   </test>
+  <test name="gtest-optional-21.cs">
+    <type name="C">
+      <method name="Void Foo(C, C)" attrs="150">
+        <size>2</size>
+      </method>
+      <method name="Void Foo2(C)" attrs="150">
+        <size>2</size>
+      </method>
+      <method name="Void Main()" attrs="150">
+        <size>2</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="gtest-partial-01.cs">
     <type name="B`1[U]">
       <method name="Void .ctor()" attrs="6278">