Avoid a crash when using attributes and only partial method definition exists.
authorMarek Safar <marek.safar@gmail.com>
Fri, 6 Aug 2010 18:24:37 +0000 (19:24 +0100)
committerMarek Safar <marek.safar@gmail.com>
Fri, 6 Aug 2010 18:28:11 +0000 (19:28 +0100)
mcs/mcs/method.cs
mcs/tests/test-partial-29.cs [new file with mode: 0644]
mcs/tests/ver-il-gmcs.xml

index 80539569b2769770b336aa28cd75c637b4565972..a99debb8065d2c96ff2730e8c1857b77998c89f9 100644 (file)
@@ -1067,16 +1067,18 @@ namespace Mono.CSharp {
                public override void Emit ()
                {
                        try {
-                               Report.Debug (64, "METHOD EMIT", this, MethodBuilder, Location, Block, MethodData);
                                if (IsPartialDefinition) {
                                        //
                                        // Use partial method implementation builder for partial method declaration attributes
                                        //
                                        if (partialMethodImplementation != null) {
                                                MethodBuilder = partialMethodImplementation.MethodBuilder;
-                                               return;
                                        }
-                               } else if ((ModFlags & Modifiers.PARTIAL) != 0 && (caching_flags & Flags.PartialDefinitionExists) == 0) {
+
+                                       return;
+                               }
+                               
+                               if ((ModFlags & Modifiers.PARTIAL) != 0 && (caching_flags & Flags.PartialDefinitionExists) == 0) {
                                        Report.Error (759, Location, "A partial method `{0}' implementation is missing a partial method declaration",
                                                GetSignatureForError ());
                                }
diff --git a/mcs/tests/test-partial-29.cs b/mcs/tests/test-partial-29.cs
new file mode 100644 (file)
index 0000000..d7ce035
--- /dev/null
@@ -0,0 +1,13 @@
+using System;
+
+static partial class C
+{
+       static partial void Foo_1 (this string s);
+
+       [Obsolete]
+       static partial void Foo_2 (string s);
+
+       static void Main()
+       {
+       }
+}
index 4b172fd868634cc184995db285955da9ec452f45..01130c1391599681d91219f6078bdee426d75421 100644 (file)
       </method>
     </type>
   </test>
+  <test name="gtest-optional-09.cs">
+    <type name="Program">
+      <method name="Int32 Test_1(Int32, SByte)">
+        <size>2</size>
+      </method>
+      <method name="Int32 Test_1[T](T)">
+        <size>2</size>
+      </method>
+      <method name="Int32 Test_1(Int32, Int64)">
+        <size>2</size>
+      </method>
+      <method name="Int32 Test_2(Int16)">
+        <size>2</size>
+      </method>
+      <method name="Int32 Test_2(Int32, SByte)">
+        <size>2</size>
+      </method>
+      <method name="Int32 Test_3(System.String)">
+        <size>2</size>
+      </method>
+      <method name="Int32 Test_3(System.String, SByte)">
+        <size>2</size>
+      </method>
+      <method name="Int32 Test_4(System.Object)">
+        <size>2</size>
+      </method>
+      <method name="Int32 Test_4(System.Object[])">
+        <size>2</size>
+      </method>
+      <method name="Int32 Test_5()">
+        <size>2</size>
+      </method>
+      <method name="Int32 Test_5(Int32, System.Object[])">
+        <size>2</size>
+      </method>
+      <method name="Int32 Test_6(System.Object[])">
+        <size>2</size>
+      </method>
+      <method name="Int32 Test_6(Int32, System.Object[])">
+        <size>2</size>
+      </method>
+      <method name="Int32 Test_7(Boolean, System.Object[])">
+        <size>2</size>
+      </method>
+      <method name="Int32 Test_7(Boolean, Int32, System.Object[])">
+        <size>2</size>
+      </method>
+      <method name="Int32 Main()">
+        <size>118</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="gtest-partial-01.cs">
     <type name="B`1[U]">
       <method name="Void .ctor()">
       </method>
     </type>
   </test>
+  <test name="test-partial-29.cs">
+    <type name="C">
+      <method name="Void Main()">
+        <size>1</size>
+      </method>
+    </type>
+  </test>
   <test name="test-var-01.cs">
     <type name="Test">
       <method name="Void .ctor()">