[Mono-bugs] [Bug 75894][Min] New - [GMCS] Generics compiler doesn't access private properties

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Aug 24 07:25:21 EDT 2005


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 norbert.groen at getronics.com.

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

--- shadow/75894	2005-08-24 07:25:21.000000000 -0400
+++ shadow/75894.tmp.13604	2005-08-24 07:25:21.000000000 -0400
@@ -0,0 +1,88 @@
+Bug#: 75894
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: C#
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: norbert.groen at getronics.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: [GMCS] Generics compiler doesn't access private properties
+
+[GMCS] Generics compiler doesn't access private properties
+
+Description of Problem:
+
+When using private properties in an generic class method. The generic
+compiler won't compile due to access problems. Protected properties are
+accepted however.
+
+Steps to reproduce the problem:
+1. listing of testsource with private property (which doesn't compile, see 2.)
+2. compile testsource
+
+1.
+$ type genPriv.cs
+using System;
+
+namespace myWorld {
+  class Super<S> {
+    S[] v;
+    int b;
+    public Super () { v= new S[10]; b=0; }
+    //!!! explicit private (=default)
+    private int slack { get{ return v.Length-b; } }
+//    //!!!  protected works around, but is not what you really want
+//    protected int slack { get{ return v.Length-b; } }
+
+    public void add(S nw) {
+    if (slack!=0)
+      v[b++]=nw;
+    }
+    public S high { get { return v[b-1]; } }
+  }
+
+  class MainClass {
+    public static void Main(string[] args) {
+      Super<string> ar= new Super<string>();
+      int i;
+      for (i=0;i!=args.Length;i+=1){
+        ar.add(args[i]);
+        Console.WriteLine(" arg {0} : {1}",i,ar.high);
+      }
+    }
+  }
+}
+
+2. 
+$ gmcs genPriv.cs
+
+
+Actual Results:
+
+$ gmcs genPriv.cs
+genPriv.cs(14) error CS0122: 'myWorld.Super`1.slack' is inaccessible due to
+its protection level
+Compilation failed: 1 error(s), 0 warnings
+
+Expected Results:
+
+Clean compile.
+
+
+How often does this happen? 
+
+Allways.
+
+
+Additional Information:
+
+$ gmcs --version
+Mono C# compiler version 1.1.5.0


More information about the mono-bugs mailing list