diff --git a/compiler/testData/codegen/box/closures/kt10044.kt b/compiler/testData/codegen/box/closures/kt10044.kt new file mode 100644 index 00000000000..277f356c76c --- /dev/null +++ b/compiler/testData/codegen/box/closures/kt10044.kt @@ -0,0 +1,41 @@ +open class JClass() { + fun test(): String { + return "OK" + } +} + +class Example : JClass { + constructor() : super() + + private var obj: JClass? = null + + var result: String? = null + + init { + { + result = obj?.test() + }() + } +} + +class Example2 : JClass { + constructor() : super() + + private var obj: JClass? = this + + var result: String? = null + + init { + { + result = obj?.test() + }() + } +} + + +fun box(): String { + val result = Example().result + if (result != null) "fail 1: $result" + + return Example2().result!! +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java index e93f54aba9b..d9f6ede4f22 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -1753,6 +1753,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("kt10044.kt") + public void testKt10044() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/closures/kt10044.kt"); + doTest(fileName); + } + @TestMetadata("kt2151.kt") public void testKt2151() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/closures/kt2151.kt");