allow null to be cast to any non-primitve

This commit is contained in:
Dave Holoway
2020-06-07 15:12:43 +01:00
parent ce6ed14aaa
commit 7d6af70ae1

View File

@@ -1072,6 +1072,10 @@ function isTypeCastable(source_type, cast_type) {
// everything is castable to Object
return true;
}
if (source_type instanceof NullType) {
// null is castable to any non-primitive
return !(cast_type instanceof PrimitiveType);
}
if (source_type instanceof CEIType && cast_type instanceof CEIType) {
if (source_type.typeKind === 'interface') {
// interfaces are castable to any non-final class type (derived types might implement the interface)