diff --git a/compiler/testData/ir/irText/classes/objectWithInitializers.kt b/compiler/testData/ir/irText/classes/objectWithInitializers.kt new file mode 100644 index 00000000000..c049dc75b64 --- /dev/null +++ b/compiler/testData/ir/irText/classes/objectWithInitializers.kt @@ -0,0 +1,9 @@ +abstract class Base + +object Test : Base() { + val x = 1 + val y: Int + init { + y = x + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/classes/objectWithInitializers.txt b/compiler/testData/ir/irText/classes/objectWithInitializers.txt new file mode 100644 index 00000000000..bb99bfe85ed --- /dev/null +++ b/compiler/testData/ir/irText/classes/objectWithInitializers.txt @@ -0,0 +1,19 @@ +FILE /objectWithInitializers.kt + CLASS CLASS Base + CONSTRUCTOR public constructor Base() + BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=Base + CLASS OBJECT Test + CONSTRUCTOR private constructor Test() + BLOCK_BODY + CALL . type=Base operator=SUPER_CONSTRUCTOR_CALL + INSTANCE_INITIALIZER_CALL classDescriptor=Test + PROPERTY public final val x: kotlin.Int = 1 + EXPRESSION_BODY + CONST Int type=kotlin.Int value='1' + PROPERTY public final val y: kotlin.Int + ANONYMOUS_INITIALIZER Test + BLOCK_BODY + SET_BACKING_FIELD y type=kotlin.Unit operator=null + CALL . type=kotlin.Int operator=GET_PROPERTY + $this: THIS public object Test : Base type=Test diff --git a/compiler/testData/ir/irText/classes/sealedClasses.kt b/compiler/testData/ir/irText/classes/sealedClasses.kt new file mode 100644 index 00000000000..f1561ef6b68 --- /dev/null +++ b/compiler/testData/ir/irText/classes/sealedClasses.kt @@ -0,0 +1,5 @@ +sealed class Expr { + class Const(val number: Double) : Expr() + class Sum(val e1: Expr, val e2: Expr) : Expr() + object NotANumber : Expr() +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/classes/sealedClasses.txt b/compiler/testData/ir/irText/classes/sealedClasses.txt new file mode 100644 index 00000000000..5733d80b40b --- /dev/null +++ b/compiler/testData/ir/irText/classes/sealedClasses.txt @@ -0,0 +1,35 @@ +FILE /sealedClasses.kt + CLASS CLASS Expr + CONSTRUCTOR private constructor Expr() + BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=Expr + CLASS CLASS Const + CONSTRUCTOR public constructor Const(/*0*/ number: kotlin.Double) + BLOCK_BODY + CALL . type=Expr operator=SUPER_CONSTRUCTOR_CALL + SET_BACKING_FIELD number type=kotlin.Unit operator=null + GET_VAR number type=kotlin.Double operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=Const + PROPERTY public final val number: kotlin.Double + EXPRESSION_BODY + GET_VAR number type=kotlin.Double operator=INITIALIZE_PROPERTY_FROM_PARAMETER + CLASS CLASS Sum + CONSTRUCTOR public constructor Sum(/*0*/ e1: Expr, /*1*/ e2: Expr) + BLOCK_BODY + CALL . type=Expr operator=SUPER_CONSTRUCTOR_CALL + SET_BACKING_FIELD e1 type=kotlin.Unit operator=null + GET_VAR e1 type=Expr operator=INITIALIZE_PROPERTY_FROM_PARAMETER + SET_BACKING_FIELD e2 type=kotlin.Unit operator=null + GET_VAR e2 type=Expr operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=Sum + PROPERTY public final val e1: Expr + EXPRESSION_BODY + GET_VAR e1 type=Expr operator=INITIALIZE_PROPERTY_FROM_PARAMETER + PROPERTY public final val e2: Expr + EXPRESSION_BODY + GET_VAR e2 type=Expr operator=INITIALIZE_PROPERTY_FROM_PARAMETER + CLASS OBJECT NotANumber + CONSTRUCTOR private constructor NotANumber() + BLOCK_BODY + CALL . type=Expr operator=SUPER_CONSTRUCTOR_CALL + INSTANCE_INITIALIZER_CALL classDescriptor=NotANumber diff --git a/compiler/testData/ir/irText/lambdas/nonLocalReturn.kt b/compiler/testData/ir/irText/lambdas/nonLocalReturn.kt index c3ca68a5efc..80d282ae0eb 100644 --- a/compiler/testData/ir/irText/lambdas/nonLocalReturn.kt +++ b/compiler/testData/ir/irText/lambdas/nonLocalReturn.kt @@ -16,3 +16,16 @@ fun test2() { } } +fun testLrmFoo1(ints: List) { + ints.forEach lit@ { + if (it == 0) return@lit + print(it) + } +} + +fun testLrmFoo2(ints: List) { + ints.forEach { + if (it == 0) return@forEach + print(it) + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt b/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt index b58124cea2c..2c599f8c0d4 100644 --- a/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt +++ b/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt @@ -23,3 +23,35 @@ FILE /nonLocalReturn.kt BLOCK_BODY RETURN type=kotlin.Nothing from= CALLABLE_REFERENCE local final fun (): kotlin.Unit type=() -> kotlin.Unit + FUN public fun testLrmFoo1(/*0*/ ints: kotlin.collections.List): kotlin.Unit + BLOCK_BODY + CALL .forEach type=kotlin.Unit operator=null + $receiver: GET_VAR ints type=kotlin.collections.List operator=null + action: BLOCK type=(kotlin.Int) -> kotlin.Unit operator=LAMBDA + FUN local final fun (/*0*/ it: kotlin.Int): kotlin.Unit + BLOCK_BODY + WHEN type=kotlin.Unit operator=IF + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR it type=kotlin.Int operator=null + arg1: CONST Int type=kotlin.Int value='0' + then: RETURN type=kotlin.Nothing from= + RETURN type=kotlin.Nothing from= + CALL .print type=kotlin.Unit operator=null + message: GET_VAR it type=kotlin.Int operator=null + CALLABLE_REFERENCE local final fun (/*0*/ it: kotlin.Int): kotlin.Unit type=(kotlin.Int) -> kotlin.Unit + FUN public fun testLrmFoo2(/*0*/ ints: kotlin.collections.List): kotlin.Unit + BLOCK_BODY + CALL .forEach type=kotlin.Unit operator=null + $receiver: GET_VAR ints type=kotlin.collections.List operator=null + action: BLOCK type=(kotlin.Int) -> kotlin.Unit operator=LAMBDA + FUN local final fun (/*0*/ it: kotlin.Int): kotlin.Unit + BLOCK_BODY + WHEN type=kotlin.Unit operator=IF + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR it type=kotlin.Int operator=null + arg1: CONST Int type=kotlin.Int value='0' + then: RETURN type=kotlin.Nothing from= + RETURN type=kotlin.Nothing from= + CALL .print type=kotlin.Unit operator=null + message: GET_VAR it type=kotlin.Int operator=null + CALLABLE_REFERENCE local final fun (/*0*/ it: kotlin.Int): kotlin.Unit type=(kotlin.Int) -> kotlin.Unit diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index c5d943b536e..88e5d4de57c 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -127,6 +127,12 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { doTest(fileName); } + @TestMetadata("objectWithInitializers.kt") + public void testObjectWithInitializers() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/classes/objectWithInitializers.kt"); + doTest(fileName); + } + @TestMetadata("primaryConstructor.kt") public void testPrimaryConstructor() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/classes/primaryConstructor.kt"); @@ -145,6 +151,12 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { doTest(fileName); } + @TestMetadata("sealedClasses.kt") + public void testSealedClasses() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/classes/sealedClasses.kt"); + doTest(fileName); + } + @TestMetadata("secondaryConstructorWithInitializersFromClassBody.kt") public void testSecondaryConstructorWithInitializersFromClassBody() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.kt");