diff options
author | jfrijters <jfrijters> | 2010-05-21 07:48:26 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2010-05-21 07:48:26 +0400 |
commit | bc23b974ef46f0cf39e186c819148e1a34b075ff (patch) | |
tree | aec45ca8bb408fc1ac7e60eb20550d56dc55402f /reflect/Type.cs | |
parent | 5aa745c75feb83054fc548831c9657102ac6c82f (diff) |
Three IsAssignableFrom fixes:
- non-vector arrays are not assignable to vector arrays
- value type arrays are not assignable to non-value type arrays (and v.v.)
- pointers can be boxed to ValueType as well as Object
Diffstat (limited to 'reflect/Type.cs')
-rw-r--r-- | reflect/Type.cs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/reflect/Type.cs b/reflect/Type.cs index bb24d431..e3692231 100644 --- a/reflect/Type.cs +++ b/reflect/Type.cs @@ -1302,9 +1302,19 @@ namespace IKVM.Reflection { return false; } - else if (this.IsArray && type.IsArray && this.GetArrayRank() == type.GetArrayRank()) + else if (this.IsArray && type.IsArray) { - return GetElementType().IsAssignableFrom(type.GetElementType()); + if (this.GetArrayRank() != type.GetArrayRank()) + { + return false; + } + else if (this.__IsVector && !type.__IsVector) + { + return false; + } + Type e1 = this.GetElementType(); + Type e2 = type.GetElementType(); + return e1.IsValueType == e2.IsValueType && e1.IsAssignableFrom(e2); } else if (this.IsSealed) { @@ -1314,10 +1324,14 @@ namespace IKVM.Reflection { return Array.IndexOf(type.GetInterfaces(), this) != -1; } - else if (type.IsInterface || type.IsPointer) + else if (type.IsInterface) { return this == this.Module.universe.System_Object; } + else if (type.IsPointer) + { + return this == this.Module.universe.System_Object || this == this.Module.universe.System_ValueType; + } else { return type.IsSubclassOf(this); |