New test.
[mono.git] / mcs / class / corlib / System.Reflection / MonoGenericClass.cs
index 5344407d6bf44217b66b6b764583cdc30033d569..345b5d99c68c21cb67a8ca94ffb3de6fb346353f 100644 (file)
@@ -56,6 +56,15 @@ namespace System.Reflection
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                protected extern void initialize (MethodInfo[] methods, ConstructorInfo[] ctors, FieldInfo[] fields, PropertyInfo[] properties, EventInfo[] events);
 
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               extern MethodInfo GetCorrespondingInflatedMethod (MethodInfo generic);
+
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               extern ConstructorInfo GetCorrespondingInflatedConstructor (ConstructorInfo generic);
+
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               extern FieldInfo GetCorrespondingInflatedField (string generic);
+
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                protected extern MethodInfo[] GetMethods_internal (Type reflected_type);
 
@@ -87,7 +96,7 @@ namespace System.Reflection
                        if (initialized)
                                return;
 
-                       MonoGenericClass parent = GetParentType ();
+                       MonoGenericClass parent = GetParentType () as MonoGenericClass;
                        if (parent != null)
                                parent.initialize ();
 
@@ -101,14 +110,14 @@ namespace System.Reflection
                }
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               protected extern MonoGenericClass GetParentType ();
+               protected extern Type GetParentType ();
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                protected extern MonoGenericClass[] GetInterfaces_internal ();
 
                public override Type BaseType {
                        get {
-                               MonoGenericClass parent = GetParentType ();
+                               Type parent = GetParentType ();
                                return parent != null ? parent : generic_type.BaseType;
                        }
                }
@@ -123,6 +132,27 @@ namespace System.Reflection
                        return generic_type.IsValueType;
                }
 
+               internal override MethodInfo GetMethod (MethodInfo fromNoninstanciated)
+               {
+                       initialize ();
+
+                       return GetCorrespondingInflatedMethod (fromNoninstanciated);
+               }
+
+               internal override ConstructorInfo GetConstructor (ConstructorInfo fromNoninstanciated)
+               {
+                       initialize ();
+
+                       return GetCorrespondingInflatedConstructor (fromNoninstanciated);
+               }
+
+               internal override FieldInfo GetField (FieldInfo fromNoninstanciated)
+               {
+                       initialize ();
+
+                       return GetCorrespondingInflatedField (fromNoninstanciated.Name);
+               }
+               
                public override MethodInfo[] GetMethods (BindingFlags bf)
                {
                        ArrayList l = new ArrayList ();
@@ -488,5 +518,28 @@ namespace System.Reflection
                {
                        return generic_type.GetNestedTypes (bf);
                }
+
+               public override bool IsAssignableFrom (Type c)
+               {
+                       if (c == this)
+                               return true;
+
+                       MonoGenericClass[] interfaces = GetInterfaces_internal ();
+
+                       if (c.IsInterface) {
+                               if (interfaces == null)
+                                       return false;
+                               foreach (Type t in interfaces)
+                                       if (c.IsAssignableFrom (t))
+                                               return true;
+                               return false;
+                       }
+
+                       Type parent = GetParentType ();
+                       if (parent == null)
+                               return c == typeof (object);
+                       else
+                               return c.IsAssignableFrom (parent);
+               }
        }
 }