[Mono-bugs] [Bug 573385] New: CS0029 on accessing a field within a generic inner class

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Jan 25 00:40:28 EST 2010


http://bugzilla.novell.com/show_bug.cgi?id=573385

http://bugzilla.novell.com/show_bug.cgi?id=573385#c0


           Summary: CS0029 on accessing a field within a generic inner
                    class
    Classification: Mono
           Product: Mono: Compilers
           Version: 2.6.x
          Platform: Other
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: ashish.kulkarni at kalyptorisk.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Community User
           Blocker: ---


When I try to use a field within a inner class which is generic, I get the
compiler error CS0029.


=== CODE ===
using System;

class Repro {
    class Outer{
        public class Inner<T> where T: class {
            public static T[] Values;
        }
    }
    static void Main ()
    {
        Outer.Inner<string>.Values = new string[0];
    }
}
============

Actual Results:

D:\>gmcs test.cs
test.cs(11,29): error CS0029: Cannot implicitly convert type `string[]' to
`T[]'

Compilation failed: 1 error(s), 0 warnings

Expected Results:

compiles successfully.

Additional Information:

However, the following code (not within an inner class) compiles successfully.

=== CODE ===
using System;

class Repro {
    public class Inner<T> where T: class {
        public static T[] Values;
    }
    static void Main ()
    {
        Inner<string>.Values = new string[0];
    }
}
============

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list