psi2ir: fix nullability assertion generation for platform types

Incorporate PR from Steven Schäfer into IrType-based implicit cast
insertion (commit 17b925636e8717e7648c5d7b792c6ab4d18f776d).

NB this still uses originalKotlinType to determine if the type was
nullability flexible. It is somewhat error-prone and something we want
to get rid of. However, it boils down to some design questions related
to implicit null checks in Kotlin - e.g., it might be Ok to just treat
nullability flexible type `T!` as `T?` in IR, generate null checks for
all usages of type `T?` where a non-null type is expected, and later
eliminate the null checks that are redundant according to the (quite
conservative) criterion in the redundant null check elimination.
This commit is contained in:
Dmitry Petrov
2019-04-16 12:01:22 +03:00
parent ab38430ded
commit 1d9cb39915
14 changed files with 276 additions and 31 deletions
@@ -1606,6 +1606,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irText/types"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt")
public void testExplicitEqualsAndCompareToCallsOnPlatformTypeReceiver() throws Exception {
runTest("compiler/testData/ir/irText/types/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt");
}
@TestMetadata("intersectionType1_NI.kt")
public void testIntersectionType1_NI() throws Exception {
runTest("compiler/testData/ir/irText/types/intersectionType1_NI.kt");
@@ -1640,5 +1645,10 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
public void testLocalVariableOfIntersectionType_NI() throws Exception {
runTest("compiler/testData/ir/irText/types/localVariableOfIntersectionType_NI.kt");
}
@TestMetadata("nullabilityAssertionOnExtensionReceiver.kt")
public void testNullabilityAssertionOnExtensionReceiver() throws Exception {
runTest("compiler/testData/ir/irText/types/nullabilityAssertionOnExtensionReceiver.kt");
}
}
}