Bug 318812 (MONO75894) - [GMCS] Generics compiler doesn't access private properties
Summary: [GMCS] Generics compiler doesn't access private properties
Status: RESOLVED FIXED
Alias: MONO75894
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Martin Baulig
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-24 14:25 UTC by Norbert Groen
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Testfile with private method in generic class (715 bytes, text/plain)
2005-08-24 18:54 UTC, Thomas Wiest
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:28:38 UTC


---- Reported by norbert.groen@getronics.com 2005-08-24 07:25:20 MST ----

[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



---- Additional Comments From norbert.groen@getronics.com 2005-08-24 11:54:01 MST ----

Created an attachment (id=168415)
Testfile with private method in generic class




---- Additional Comments From martin@ximian.com 2005-09-05 13:05:15 MST ----

Works for me.



---- Additional Comments From norbert.groen@getronics.com 2005-09-13 06:26:03 MST ----

Martin,

The attached source works indeed, I forgot to change it to the non-
working version.
Please change the source to use the private instead of the protected 
version:
     private int slack { get{ return v.Length-b; } }
//   protected int slack { get{ return v.Length-b; } }

Does that still work for you?
Mind you, I'm using the 1.1.5.0 version of gmcs from the 1.1.8.3 mono-
package for windows (on win2000 platform).

gr,

Norbert.





---- Additional Comments From martin@ximian.com 2005-10-04 07:59:46 MST ----

Fixed long ago.

Imported an attachment (id=168415)

Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>Windows 2000</cf_op_sys_details>
Unknown bug field "cf_version_details" encountered while moving bug
   <cf_version_details>1.1.5.0</cf_version_details>
Unknown operating system unknown. Setting to default OS "Other".