[Mono-bugs] [Bug 28607][Nor] New - mcs treats protected fields/methods as public

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
6 Aug 2002 02:43:00 -0000


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by gonzalo@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=28607

--- shadow/28607	Mon Aug  5 22:43:00 2002
+++ shadow/28607.tmp.11136	Mon Aug  5 22:43:00 2002
@@ -0,0 +1,61 @@
+Bug#: 28607
+Product: Mono/MCS
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: gonzalo@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: mcs treats protected fields/methods as public
+
+Description of Problem:
+mcs treats protected fields/methods as public.
+
+Steps to reproduce the problem:
+1. Compile this program:
+using System;
+
+class A
+{
+        protected int n;
+        protected void Method ()
+        {
+                Console.WriteLine ("In A.Method")
+        }
+}
+
+class MyClass
+{
+        public static void Main (string [] args)
+        {
+                A b = new A ();
+                b.n = 1;
+                b.Method ();
+        }
+}
+
+Actual Results:
+Compilation succedeed
+
+
+Expected Results:
+test.cs(17,3): error CS0122: 'A.n' is inaccessible due to its protection level
+test.cs(18,3): error CS0122: 'A.Method()' is inaccessible due to its
+protection level
+
+Additional information:
+If you make MyClass derive from A, mcs still compiles it and csc reports:
+test.cs(17,3): error CS1540: Cannot access protected member 'A.n' via a
+qualifier of type 'A'; the qualifier
+        must be of type 'MyClass' (or derived from it)
+test.cs(18,3): error CS1540: Cannot access protected member 'A.Method()'
+via a qualifier of type 'A'; the
+        qualifier must be of type 'MyClass' (or derived from it)