[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


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

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


           Summary: Problem when using Reflection.Emit to create a class
                    derived from an abstract class containing a Generic
                    property
    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
http://www.microsoft.com/downloads/details.aspx?FamilyID=b55f0532-ac3c-4106-918c-5586a953a7da&displaylang=en

2. Run FSI.exe through Mono

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

[<AbstractClass>]
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:  
Result:
error FS0193: Operation is not supported.


Expected Results:  
Expected:
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,
System.Reflection.Paramet
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
unknown>:0
  at
Microsoft.FSharp.Compiler.AbstractIL.RuntimeWriter.TypeBuilder.CreateTypeAndLog
(System.Reflect
ion.Emit.TypeBuilder ) [0x00000] in <filename unknown>:0
  at
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