[Mono-bugs] [Bug 469858] New: [regression] crash if using constrained generic parameter in nested class

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Jan 27 12:39:58 EST 2009


https://bugzilla.novell.com/show_bug.cgi?id=469858


           Summary: [regression] crash if using constrained generic
                    parameter in nested class
    Classification: Mono
           Product: Mono: Runtime
           Version: 2.4.x
          Platform: x86-64
        OS/Version: Kubuntu
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: generics
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: silk at boktor.net
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Created an attachment (id=268028)
 --> (https://bugzilla.novell.com/attachment.cgi?id=268028)
test case

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5)
Gecko/2008121621 Ubuntu/8.04 (hardy) Firefox/3.0.5

This code compiles fine. Works under MS.NET, and mono up to mono 2.0.
It throws exception in mono 2.2, or current mono 2.4 branch.

It seems to work fine with mono trunk from rev r124177 in my friend's
environment.


public class P
{
    public int Metoda () { return 2; }
}

public class Packer<T> where T : P
{
    class Node {
        public void Insert(T item)
        {
            System.Console.WriteLine (item.Metoda());
        }
    }

    public void M (T item) {
        System.Console.WriteLine (item.Metoda());
        Node n = new Node ();
        n.Insert (item);
    }
}

public class T {
    public static void Main ()
    {
        Packer<P> pack = new Packer<P> ();
        pack.M (new P ());
    }

}


Same code in attachement.

Reproducible: Always

Steps to Reproduce:
1. Create a generic class A<T> with a constrint T : SomeClass
2. Create a nested non-generic class B in A<T>
3. Add a method B.Met(T item)
4. Call from B.Met some method existing in SomeClass
5. Compile & run

Actual Results:  
Runtime exception:
** (NestedGeneric.exe:28410): WARNING **: Missing method .P.Metoda in assembly
/home/silk/devel/test/bugs/iface/NestedGeneric.exe token 6000002

Unhandled Exception: System.TypeLoadException: A type load exception has
occurred.
  at Packer`1[P].M (.P item) [0x00018] in
/home/silk/devel/test/bugs/iface/NestedGeneric.cs:18
  at T.Main () [0x00006] in
/home/silk/devel/test/bugs/iface/NestedGeneric.cs:26



Expected Results:  
Does not crash. The method is sucessfully called.

OpenTK.Fonts library requires this to work.

-- 
Configure bugmail: https://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