Bugzilla – Bug 324195
[GMCS] Incorrectly checks generic type member accessibility
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by mike.allen@durrusa.com 2007-05-02 14:11:23 MST ---- Description of Problem: I'm using gmcs version 1.2.3.1 (mono-gmcs package supplied by Ubuntu 7.04). Consider the following code: namespace Test { public class Test <T> where T: Test <T> { private int someData; public void Copy (T other) { someData = other.someData; } } } (Now, I'm not saying that this is a good example of a generic copy method, but still... ;-) If you compile this, the gmcs compiler complains about the "other.someData" reference saying that it is inaccessible due to its protection level. As a workaround, I found that I need to cast "other" as follows: namespace Test { public class Test <T> where T: Test <T> { private int someData; public void Copy (T other) { Test <T> fudge = other; someData = fudge.someData; } } } and this compiles OK. Steps to reproduce the problem: 1. Copy the first code example above into a file called "test.cs". 2. Compile this file with the command: gmcs -target:library -warn:4 -warnaserror test.cs Actual Results: Get the following compiler output: test.cs(10,30): error CS0122: `Test.Test<T>.someData' is inaccessible due to its protection level test.cs(7,21): (Location of the symbol related to previous error) Compilation failed: 1 error(s), 0 warnings Expected Results: Clean compile with no errors. How often does this happen? Every time. Additional Information: Compiles clean with Microsoft C# version 8.00.50727.42 ---- Additional Comments From mike.allen@durrusa.com 2007-05-02 14:12:46 MST ---- Created an attachment (id=171901) Problem code as a source file ---- Additional Comments From gert.driesen@pandora.be 2007-05-15 14:57:07 MST ---- This works fine using gmcs from SVN. Imported an attachment (id=171901) Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>Ubuntu 7.04</cf_op_sys_details> Unknown operating system unknown. Setting to default OS "Other".