[Mono-bugs] [Bug 34522][Nor] New - mcs incorrectly reports some fields inaccessible

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
23 Nov 2002 05:25:31 -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 mathpup@mylinuxisp.com.

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

--- shadow/34522	Sat Nov 23 00:25:31 2002
+++ shadow/34522.tmp.15310	Sat Nov 23 00:25:31 2002
@@ -0,0 +1,85 @@
+Bug#: 34522
+Product: Mono/MCS
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: mathpup@mylinuxisp.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: mcs incorrectly reports some fields inaccessible
+
+Description of Problem: 
+ 
+When a protected field is declared in a base class, and a method in the base class 
+attempts to access that field through a variable whose static type is a derived class, mcs 
+reports that the field is not accessible. I have included a test case that illustrates the bug: 
+ 
+using System; 
+ 
+public class Base 
+{ 
+	protected bool flag = false; 
+	protected Derived derived; 
+	 
+	 
+	public virtual bool Flag 
+	{ 
+		get { return flag; } 
+	} 
+	 
+	 
+	public virtual void Method() 
+	{ 
+		Console.WriteLine(derived.flag); 
+	} 
+	 
+} 
+ 
+ 
+public class Derived: Base {} 
+ 
+ 
+public class Testing 
+{ 
+	public static void Main() 
+	{ 
+		Derived r = new Derived(); 
+		Console.WriteLine(r.Flag); 
+	} 
+} 
+ 
+ 
+Steps to reproduce the problem: 
+1. Run mcs testcase.cs 
+ 
+ 
+Actual Results: 
+ 
+mcs reports an error: 
+protected.cs(18) error CS0122: `Derived.flag' is inaccessible because of its protection 
+level 
+ 
+ 
+Expected Results: 
+ 
+Successful compilation 
+ 
+ 
+How often does this happen?  
+ 
+Always 
+ 
+Additional Information: 
+ 
+csc compiles the program without complaint. I realize that the example here looks a little 
+contrived and that a real program would need to initialize the field "derived" at some 
+point. However, this is the same error that causes Menu.cs in System.Windows.Forms to 
+fail during compilation with similar errors on lines 135, 156, and 159.