2010-04-08 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 8 Apr 2010 14:53:25 +0000 (14:53 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Thu, 8 Apr 2010 14:53:25 +0000 (14:53 -0000)
* AssemblyBuilder.cs (GenericInstanceKey): Precalculate
GenericInstanceKey hash code since this can cause infinite
recursion when inflating "Foo<T> : Bar<Foo<T>>" parent.

* TypeBuilder.cs (IsSubclassOf): Don't delegate to base class
since the unmanaged information can be out of sync.

* TypeBuilder.cs (UnderlyingSystemType): Invert the test order
since IsEnum now is potentialy more expensive.

Fixes #594728.

svn path=/trunk/mcs/; revision=155053

mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
mcs/class/corlib/System.Reflection.Emit/ChangeLog
mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs

index e99f610d56c4b0b4c96728f43edceeab108b38b3..903c779b11d802570e17cb5516f07ac5ed186086 100644 (file)
@@ -93,11 +93,16 @@ namespace System.Reflection.Emit
        internal class GenericInstanceKey {
                Type gtd;
                internal Type[] args;
+               int hash_code;
 
                internal GenericInstanceKey (Type gtd, Type[] args)
                {
                        this.gtd = gtd;
                        this.args = args;
+
+                       hash_code = gtd.GetHashCode ();
+                       for (int i = 0; i < args.Length; ++i)
+                               hash_code ^= args [i].GetHashCode ();
                }
 
                static bool IsBoundedVector (Type type) {
@@ -193,10 +198,7 @@ namespace System.Reflection.Emit
 
                public override int GetHashCode ()
                {
-                       int hash = gtd.GetHashCode ();
-                       for (int i = 0; i < args.Length; ++i)
-                               hash ^= args [i].GetHashCode ();
-                       return hash;
+                       return hash_code;
                }
        }
 
index 00ac6d6091e188a75656c56657c7f5d54d06151b..06bb74f0b9dbce821b0dc987fc148a23ff7ede39 100644 (file)
@@ -1,3 +1,17 @@
+2010-04-08 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * AssemblyBuilder.cs (GenericInstanceKey): Precalculate
+       GenericInstanceKey hash code since this can cause infinite
+       recursion when inflating "Foo<T> : Bar<Foo<T>>" parent.
+
+       * TypeBuilder.cs (IsSubclassOf): Don't delegate to base class
+       since the unmanaged information can be out of sync.
+
+       * TypeBuilder.cs (UnderlyingSystemType): Invert the test order
+       since IsEnum now is potentialy more expensive.
+
+       Fixes #594728.
+
 2010-04-06  Marek Safar  <marek.safar@gmail.com>
 
        * ModuleBuilder.cs: Use Dictionary.
index a4b7185428dd8c16214bd05e96894e3151b483c3..aad2a0e641f9990eb5d097a92c982164b520dae1 100644 (file)
@@ -173,7 +173,8 @@ namespace System.Reflection.Emit
                        get { return nesting_type; }
                }
 
-/*             public override bool IsSubclassOf (Type c)
+               [ComVisible (true)]
+               public override bool IsSubclassOf (Type c)
                {
                        Type t;
                        if (c == null)
@@ -187,14 +188,14 @@ namespace System.Reflection.Emit
                                t = t.BaseType;
                        }
                        return false;
-               }*/
+               }
 
                public override Type UnderlyingSystemType {
                        get {
                                if (is_created)
                                        return created.UnderlyingSystemType;
 
-                               if (IsEnum && !IsCompilerContext) {
+                               if (!IsCompilerContext && IsEnum) {
                                        if (underlying_type != null)
                                                return underlying_type;
                                        throw new InvalidOperationException (
@@ -1676,13 +1677,6 @@ namespace System.Reflection.Emit
                        return base.IsAssignableFrom (c);
                }
 
-               [ComVisible (true)]
-               [MonoTODO]
-               public override bool IsSubclassOf (Type c)
-               {
-                       return base.IsSubclassOf (c);
-               }
-
                [MonoTODO ("arrays")]
                internal bool IsAssignableTo (Type c)
                {