Bug 324195 (MONO81517) - [GMCS] Incorrectly checks generic type member accessibility
Summary: [GMCS] Incorrectly checks generic type member accessibility
Status: RESOLVED FIXED
Alias: MONO81517
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.2
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Raja R Harinath
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-02 21:11 UTC by Mike Allen
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
Problem code as a source file (212 bytes, text/plain)
2007-05-02 21:12 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 20:37:24 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".