Don't import static members of interfaces. Fixes #6552
authorMarek Safar <marek.safar@gmail.com>
Tue, 4 Sep 2012 11:45:43 +0000 (13:45 +0200)
committerMarek Safar <marek.safar@gmail.com>
Tue, 4 Sep 2012 11:47:24 +0000 (13:47 +0200)
mcs/mcs/import.cs
mcs/tests/test-851-lib.il [new file with mode: 0644]
mcs/tests/test-851.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_5.xml

index 605db44fb538b6a0059daa28cd247c52fd177bfe..f8c7bb8bf55a31fd6c6e6c4db0547d67f7737824 100644 (file)
@@ -1974,6 +1974,10 @@ namespace Mono.CSharp
                                foreach (var member in all) {
                                        switch (member.MemberType) {
                                        case MemberTypes.Constructor:
+                                               if (declaringType.IsInterface)
+                                                       continue;
+
+                                               goto case MemberTypes.Method;
                                        case MemberTypes.Method:
                                                MethodBase mb = (MethodBase) member;
                                                var attrs = mb.Attributes;
@@ -2094,6 +2098,9 @@ namespace Mono.CSharp
                                                throw new NotImplementedException (member.ToString ());
                                        }
 
+                                       if (imported.IsStatic && declaringType.IsInterface)
+                                               continue;
+
                                        cache.AddMemberImported (imported);
                                }
                        }
diff --git a/mcs/tests/test-851-lib.il b/mcs/tests/test-851-lib.il
new file mode 100644 (file)
index 0000000..a3bbcb7
--- /dev/null
@@ -0,0 +1,32 @@
+.assembly extern mscorlib
+{
+}
+
+.assembly 'test-851-lib'
+{
+  .hash algorithm 0x00008004
+}
+
+.module 'test-851-lib.dll'
+
+.class interface public auto ansi abstract I
+{
+  .field  public static initonly  int32 'value'
+
+  .method public static specialname rtspecialname 
+           default void '.cctor' ()  cil managed 
+  {
+    ret
+  }
+
+  .method public static specialname 
+           default void '__<clinit>' ()  cil managed noinlining 
+  {
+    ret 
+  }
+
+  .class nested public auto ansi abstract sealed __Fields
+    extends [mscorlib]System.Object
+  {
+  }
+}
diff --git a/mcs/tests/test-851.cs b/mcs/tests/test-851.cs
new file mode 100644 (file)
index 0000000..45cd669
--- /dev/null
@@ -0,0 +1,10 @@
+// Compiler options: -r:test-851-lib.dll
+
+public class C : I
+{
+       public static void Main ()
+       {
+
+       }
+}
+
index b61237acaa6052d52b89a4404b33e3a6280f5d59..4068df658b434147657739501027a33512a958dd 100644 (file)
       </method>\r
     </type>\r
   </test>\r
+  <test name="test-851.cs">\r
+    <type name="C">\r
+      <method name="Void Main()" attrs="150">\r
+        <size>2</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+  </test>\r
   <test name="test-86.cs">\r
     <type name="T.T">\r
       <method name="Int32 method1(System.Type, Int32)" attrs="145">\r