JS_IR: fix typecheck corner case

Consider `fun <E : I> foo(a: Any?) = a as? E`, where I is an interface.
This check used to fail, because the `a == null` was missing, and
the `isInterface` stdlib method crashes if the first argument
is null. This change adds the null check.

Also this change prettifies the instance check in case of type parameter
left operand.
This commit is contained in:
Anton Bannykh
2019-12-13 18:29:22 +03:00
committed by Anton Bannykh
parent 9a971172c9
commit d6fcde7316
10 changed files with 47 additions and 5 deletions
@@ -2821,6 +2821,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/casts/notIs.kt");
}
@TestMetadata("nullableSafeCastToTypeParameterWithInterfaceUpperBound.kt")
public void testNullableSafeCastToTypeParameterWithInterfaceUpperBound() throws Exception {
runTest("compiler/testData/codegen/box/casts/nullableSafeCastToTypeParameterWithInterfaceUpperBound.kt");
}
@TestMetadata("unitAsAny.kt")
public void testUnitAsAny() throws Exception {
runTest("compiler/testData/codegen/box/casts/unitAsAny.kt");