diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2017-06-13 18:47:36 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2017-06-13 18:47:36 +0900 |
commit | 61d6a817e39d3bae0f47dbc09838d51db22a5d30 (patch) | |
tree | cb37caa1784bc738b976273335d6ed04a7cc80b0 /src/vm/typedesc.cpp | |
parent | 5b975f8233e8c8d17b215372f89ca713b45d6a0b (diff) | |
download | coreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.tar.gz coreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.tar.bz2 coreclr-61d6a817e39d3bae0f47dbc09838d51db22a5d30.zip |
Imported Upstream version 2.0.0.11992upstream/2.0.0.11992
Diffstat (limited to 'src/vm/typedesc.cpp')
-rw-r--r-- | src/vm/typedesc.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/vm/typedesc.cpp b/src/vm/typedesc.cpp index d05cb558bc..06170cb2c1 100644 --- a/src/vm/typedesc.cpp +++ b/src/vm/typedesc.cpp @@ -441,15 +441,17 @@ BOOL TypeDesc::CanCastTo(TypeHandle toType, TypeHandlePairList *pVisited) // then we must be trying to cast to a class or interface type. if (!toType.IsTypeDesc()) { - MethodTable *pMT = GetMethodTable(); - if (pMT == 0) { - // I don't have an underlying method table, therefore I'm - // a variable type, pointer type, function pointer type + if (!IsArray()) + { + // I am a variable type, pointer type, function pointer type // etc. I am not an object or value type. Therefore // I can't be cast to an object or value type. return FALSE; } + MethodTable *pMT = GetMethodTable(); + _ASSERTE(pMT != 0); + // This does the right thing if 'type' == System.Array or System.Object, System.Clonable ... if (pMT->CanCastToClassOrInterface(toType.AsMethodTable(), pVisited) != 0) { @@ -609,15 +611,17 @@ TypeHandle::CastResult TypeDesc::CanCastToNoGC(TypeHandle toType) // then we must be trying to cast to a class or interface type. if (!toType.IsTypeDesc()) { - MethodTable *pMT = GetMethodTable(); - if (pMT == 0) { - // I don't have an underlying method table, therefore I'm - // a variable type, pointer type, function pointer type + if (!IsArray()) + { + // I am a variable type, pointer type, function pointer type // etc. I am not an object or value type. Therefore // I can't be cast to an object or value type. return TypeHandle::CannotCast; } + MethodTable *pMT = GetMethodTable(); + _ASSERTE(pMT != 0); + // This does the right thing if 'type' == System.Array or System.Object, System.Clonable ... return pMT->CanCastToClassOrInterfaceNoGC(toType.AsMethodTable()); } |