[Mono-bugs] [Bug 591225] New: Problem when using Reflection.Emit to create a class derived from an abstract class containing a Generic property

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Mar 25 15:15:13 EDT 2010



           Summary: Problem when using Reflection.Emit to create a class
                    derived from an abstract class containing a Generic
    Classification: Mono
           Product: Mono: Runtime
           Version: 2.6.x
          Platform: x86
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: generics
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: joe at noteven.org
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

User-Agent:       Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64;
Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729;
Media Center PC 6.0; MS-RTC LM 8; InfoPath.2; .NET4.0C; .NET4.0E)

It seems that when using the Reflection.Emit APIs to create a child class of an
abstract generic class, the parent class isn't specialized when it comes time
for the TypeBuilder to create the type.  This seems to only be the case for
abstract classes - generic interfaces work properly.

Reproducible: Always

Steps to Reproduce:
1.Download the latest F# CTP

2. Run FSI.exe through Mono

3. Enter the following code fragment into fsi.exe:

type B<'a> =
  abstract A : 'a with get,set

type C = 
    inherit B<int>

    override x.A
        with get() = 3
        and set(v : int) = ();;

Actual Results:  
error FS0193: Operation is not supported.

Expected Results:  
No error.

Here’s a partial stack trace captured from the NotSupportedException:

error FS0192: internal error: CreateType: Exception type
System.NotSupportedException: Operation is
not supported.
  at System.Reflection.MonoGenericClass.GetConstructorImpl (BindingFlags
bindingAttr, System.Reflect
ion.Binder binder, CallingConventions callConvention, System.Type[] types,
erModifier[] modifiers) [0x00000] in <filename unknown>:0
  at System.Type.GetConstructor (BindingFlags bindingAttr,
System.Reflection.Binder binder, CallingC
onventions callConvention, System.Type[] types,
System.Reflection.ParameterModifier[] modifiers) [0x
00000] in <filename unknown>:0
  at System.Type.GetConstructor (BindingFlags bindingAttr,
System.Reflection.Binder binder, System.T
ype[] types, System.Reflection.ParameterModifier[] modifiers) [0x00000] in
<filename unknown>:0
  at System.Reflection.Emit.TypeBuilder.DefineDefaultConstructor
(MethodAttributes attributes) [0x00
000] in <filename unknown>:0
  at System.Reflection.Emit.TypeBuilder.CreateType () [0x00000] in <filename
ion.Emit.TypeBuilder ) [0x00000] in <filename unknown>:0
Microsoft.FSharp.Compiler.AbstractIL.RuntimeWriter+traverseTypeRef at 1816.Invoke
(Int32 priority,

As far as I can tell, when setting the parent of type C to type B<int>,
MakeGenericType is called on the System.Type object for B, but the type object
returned is a MonoGenericClass, not a System.Type, as it should be.  (I guess
MonoGenericClass is equivalent to
System.Reflection.Emit.TypeBuilderInstantiation on the Microsoft CLR?)  It
looks like the abstract parent class isn’t being properly specialized.

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