[mcs] Fixes inconsistent accessibility check for partial types. Fixes #37232
authorMarek Safar <marek.safar@gmail.com>
Mon, 11 Jan 2016 12:30:53 +0000 (13:30 +0100)
committerMarek Safar <marek.safar@gmail.com>
Mon, 11 Jan 2016 12:51:02 +0000 (13:51 +0100)
mcs/errors/cs0051-3.cs [new file with mode: 0644]
mcs/mcs/decl.cs

diff --git a/mcs/errors/cs0051-3.cs b/mcs/errors/cs0051-3.cs
new file mode 100644 (file)
index 0000000..55041ee
--- /dev/null
@@ -0,0 +1,17 @@
+// CS0051: Inconsistent accessibility: parameter type `NV' is less accessible than method `C1.Foo(NV)'
+// Line: 14
+
+internal class NV
+{
+}
+
+public partial class C1
+{
+}
+
+partial class C1
+{
+       public void Foo (NV arg)
+       {
+       }
+}
\ No newline at end of file
index a386ab18b3bab8e955d5d175fc99d843ff495d43..3f88a5935c00d273a3ed3f2fc5995b4cc456f7d0 100644 (file)
@@ -524,6 +524,9 @@ namespace Mono.CSharp {
                        while (TypeManager.HasElementType (p))
                                p = TypeManager.GetElementType (p);
 
+                       if (p.BuiltinType != BuiltinTypeSpec.Type.None)
+                               return true;
+
                        if (p.IsGenericParameter)
                                return true;
 
@@ -543,6 +546,10 @@ namespace Mono.CSharp {
 
                                bool same_access_restrictions = false;
                                for (MemberCore mc = this; !same_access_restrictions && mc != null && mc.Parent != null; mc = mc.Parent) {
+                                       var tc = mc as TypeContainer;
+                                       if (tc != null && tc.PartialContainer != null)
+                                               mc = tc.PartialContainer;
+
                                        var al = mc.ModFlags & Modifiers.AccessibilityMask;
                                        switch (pAccess) {
                                        case Modifiers.INTERNAL: