JVM_IR KT-50076 don't null check moved dispatch receiver parameter

This commit is contained in:
Dmitry Petrov
2021-12-09 13:28:28 +03:00
committed by Space
parent b1d1f87318
commit 94bb465e62
5 changed files with 30 additions and 1 deletions
@@ -3962,6 +3962,12 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/interfaces/noAnyMethodsOnInterfaceInheritance.kt");
}
@Test
@TestMetadata("noNullCheckOnThisInDefaultMethod.kt")
public void testNoNullCheckOnThisInDefaultMethod() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/interfaces/noNullCheckOnThisInDefaultMethod.kt");
}
@Test
@TestMetadata("noPrivateMemberInJavaInterface.kt")
public void testNoPrivateMemberInJavaInterface() throws Exception {
@@ -321,7 +321,10 @@ class ExpressionCodegen(
irFunction.origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA
private fun generateNonNullAssertion(param: IrValueParameter) {
if (param.origin == JvmLoweredDeclarationOrigin.FIELD_FOR_OUTER_THIS) return
if (param.origin == JvmLoweredDeclarationOrigin.FIELD_FOR_OUTER_THIS ||
param.origin == IrDeclarationOrigin.MOVED_DISPATCH_RECEIVER
)
return
val asmType = param.type.asmType
if (!param.type.unboxInlineClass().isNullable() && !isPrimitive(asmType)) {
mv.load(findLocalIndex(param.symbol), asmType)
@@ -0,0 +1,8 @@
interface Test {
fun foo() = "abc"
fun String.bar() = "def"
}
// 1 check
// ^ no null check for dispatch receiver parameters in 'foo' and 'bar',
// extension receiver parameter in 'bar' is checked
@@ -3818,6 +3818,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/interfaces/noAnyMethodsOnInterfaceInheritance.kt");
}
@Test
@TestMetadata("noNullCheckOnThisInDefaultMethod.kt")
public void testNoNullCheckOnThisInDefaultMethod() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/interfaces/noNullCheckOnThisInDefaultMethod.kt");
}
@Test
@TestMetadata("noPrivateMemberInJavaInterface.kt")
public void testNoPrivateMemberInJavaInterface() throws Exception {
@@ -3962,6 +3962,12 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/interfaces/noAnyMethodsOnInterfaceInheritance.kt");
}
@Test
@TestMetadata("noNullCheckOnThisInDefaultMethod.kt")
public void testNoNullCheckOnThisInDefaultMethod() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/interfaces/noNullCheckOnThisInDefaultMethod.kt");
}
@Test
@TestMetadata("noPrivateMemberInJavaInterface.kt")
public void testNoPrivateMemberInJavaInterface() throws Exception {