KT-46267 JVM_IR don't generate unnecessary ATHROW in lateinit var read
This commit is contained in:
+6
@@ -29217,6 +29217,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/properties/lateinit/kt30548.kt");
|
runTest("compiler/testData/codegen/box/properties/lateinit/kt30548.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt46267.kt")
|
||||||
|
public void testKt46267() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/properties/lateinit/kt46267.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("localClass.kt")
|
@TestMetadata("localClass.kt")
|
||||||
public void testLocalClass() throws Exception {
|
public void testLocalClass() throws Exception {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
|||||||
import org.jetbrains.kotlin.backend.common.DefaultMapping
|
import org.jetbrains.kotlin.backend.common.DefaultMapping
|
||||||
import org.jetbrains.kotlin.backend.common.Mapping
|
import org.jetbrains.kotlin.backend.common.Mapping
|
||||||
import org.jetbrains.kotlin.backend.common.ir.Ir
|
import org.jetbrains.kotlin.backend.common.ir.Ir
|
||||||
import org.jetbrains.kotlin.backend.common.lower.irThrow
|
|
||||||
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
|
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
|
||||||
import org.jetbrains.kotlin.backend.common.psi.PsiErrorBuilder
|
import org.jetbrains.kotlin.backend.common.psi.PsiErrorBuilder
|
||||||
import org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen
|
import org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen
|
||||||
@@ -29,7 +28,6 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
|||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.builders.IrBuilderWithScope
|
import org.jetbrains.kotlin.ir.builders.IrBuilderWithScope
|
||||||
import org.jetbrains.kotlin.ir.builders.irBlock
|
import org.jetbrains.kotlin.ir.builders.irBlock
|
||||||
import org.jetbrains.kotlin.ir.builders.irNull
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||||
@@ -161,7 +159,6 @@ class JvmBackendContext(
|
|||||||
override fun throwUninitializedPropertyAccessException(builder: IrBuilderWithScope, name: String): IrExpression =
|
override fun throwUninitializedPropertyAccessException(builder: IrBuilderWithScope, name: String): IrExpression =
|
||||||
builder.irBlock {
|
builder.irBlock {
|
||||||
+super.throwUninitializedPropertyAccessException(builder, name)
|
+super.throwUninitializedPropertyAccessException(builder, name)
|
||||||
+irThrow(irNull())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleDeepCopy(
|
override fun handleDeepCopy(
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
|
// CHECK_BYTECODE_TEXT
|
||||||
|
// 0 ATHROW
|
||||||
|
// -- invoking throwUninitializedPropertyAccessException is enough
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
private lateinit var z: String
|
||||||
|
|
||||||
|
fun test(): String {
|
||||||
|
z = "OK"
|
||||||
|
return z
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return Test().test()
|
||||||
|
}
|
||||||
+6
@@ -29181,6 +29181,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/properties/lateinit/kt30548.kt");
|
runTest("compiler/testData/codegen/box/properties/lateinit/kt30548.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt46267.kt")
|
||||||
|
public void testKt46267() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/properties/lateinit/kt46267.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("localClass.kt")
|
@TestMetadata("localClass.kt")
|
||||||
public void testLocalClass() throws Exception {
|
public void testLocalClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -29217,6 +29217,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/properties/lateinit/kt30548.kt");
|
runTest("compiler/testData/codegen/box/properties/lateinit/kt30548.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt46267.kt")
|
||||||
|
public void testKt46267() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/properties/lateinit/kt46267.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("localClass.kt")
|
@TestMetadata("localClass.kt")
|
||||||
public void testLocalClass() throws Exception {
|
public void testLocalClass() throws Exception {
|
||||||
|
|||||||
+5
@@ -24797,6 +24797,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/properties/lateinit/exceptionGetter.kt");
|
runTest("compiler/testData/codegen/box/properties/lateinit/exceptionGetter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt46267.kt")
|
||||||
|
public void testKt46267() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/properties/lateinit/kt46267.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("localClass.kt")
|
@TestMetadata("localClass.kt")
|
||||||
public void testLocalClass() throws Exception {
|
public void testLocalClass() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/properties/lateinit/localClass.kt");
|
runTest("compiler/testData/codegen/box/properties/lateinit/localClass.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user