Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/ikvm-fork.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjfrijters <jfrijters>2010-06-28 16:14:24 +0400
committerjfrijters <jfrijters>2010-06-28 16:14:24 +0400
commit0399c35f8c5b3215a4a000c3d4b58993abb720db (patch)
tree25815cd9872ca8061c0e359e3c4088989a813495 /reflect/Type.cs
parentbac98d4479fbb26a68dfa9271c44724c33cbd56e (diff)
Re-instroduced generic type instantation for "identity" instantations of TypeBuilder types. This is required to be able to distinguish the two types in this example:
class Foo<T> { void Frob() { Console.WriteLine(typeof(Foo<>)); Console.WriteLine(typeof(Foo<T>)); } }
Diffstat (limited to 'reflect/Type.cs')
-rw-r--r--reflect/Type.cs31
1 files changed, 24 insertions, 7 deletions
diff --git a/reflect/Type.cs b/reflect/Type.cs
index 7b158850..da17043b 100644
--- a/reflect/Type.cs
+++ b/reflect/Type.cs
@@ -2032,17 +2032,34 @@ namespace IKVM.Reflection
internal static Type Make(Type type, Type[] typeArguments, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers)
{
- // we must not instantiate the identity instance, because typeof(Foo<>).MakeGenericType(typeof(Foo<>).GetGenericArguments()) == typeof(Foo<>)
- for (int i = 0; i < typeArguments.Length; i++)
+ bool identity = true;
+ if (type is TypeBuilder || type is BakedType)
{
- if (typeArguments[i] != type.GetGenericTypeArgument(i)
- || !IsEmpty(requiredCustomModifiers, i)
- || !IsEmpty(optionalCustomModifiers, i))
+ // a TypeBuiler identity must be instantiated
+ identity = false;
+ }
+ else
+ {
+ // we must not instantiate the identity instance, because typeof(Foo<>).MakeGenericType(typeof(Foo<>).GetGenericArguments()) == typeof(Foo<>)
+ for (int i = 0; i < typeArguments.Length; i++)
{
- return type.Module.CanonicalizeType(new GenericTypeInstance(type, typeArguments, requiredCustomModifiers, optionalCustomModifiers));
+ if (typeArguments[i] != type.GetGenericTypeArgument(i)
+ || !IsEmpty(requiredCustomModifiers, i)
+ || !IsEmpty(optionalCustomModifiers, i))
+ {
+ identity = false;
+ break;
+ }
}
}
- return type;
+ if (identity)
+ {
+ return type;
+ }
+ else
+ {
+ return type.Module.CanonicalizeType(new GenericTypeInstance(type, typeArguments, requiredCustomModifiers, optionalCustomModifiers));
+ }
}
private static bool IsEmpty(Type[][] mods, int i)