diff --git a/compiler/testData/codegen/script/classLiteralInsideFunction.kts b/compiler/testData/codegen/script/classLiteralInsideFunction.kts new file mode 100644 index 00000000000..d700791dfea --- /dev/null +++ b/compiler/testData/codegen/script/classLiteralInsideFunction.kts @@ -0,0 +1,19 @@ +package script.long.name.inside.packag + +interface I { + fun g(): I +} + +fun f(): I { + return object : I { + override fun g() = object : I { + override fun g(): I = this + + override fun toString() = "OK" + } + } +} + +val rv = f().g().g().g() + +// expected: rv: OK \ No newline at end of file diff --git a/compiler/testData/codegen/script/localFunction.kts b/compiler/testData/codegen/script/localFunction.kts new file mode 100644 index 00000000000..3e4d2043283 --- /dev/null +++ b/compiler/testData/codegen/script/localFunction.kts @@ -0,0 +1,11 @@ +package script + +fun f(j: Int): Int { + fun g(i: Int) = i * i *j + + return g(g(j)) +} + +val rv = f(2) + +// expected: rv: 128 \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ScriptCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ScriptCodegenTestGenerated.java index f6998ec4a7a..e83dd98ac78 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ScriptCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ScriptCodegenTestGenerated.java @@ -41,6 +41,12 @@ public class ScriptCodegenTestGenerated extends AbstractScriptCodegenTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/script"), Pattern.compile("^(.+)\\.kts$"), true); } + @TestMetadata("classLiteralInsideFunction.kts") + public void testClassLiteralInsideFunction() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/script/classLiteralInsideFunction.kts"); + doTest(fileName); + } + @TestMetadata("empty.kts") public void testEmpty() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/script/empty.kts"); @@ -59,6 +65,12 @@ public class ScriptCodegenTestGenerated extends AbstractScriptCodegenTest { doTest(fileName); } + @TestMetadata("localFunction.kts") + public void testLocalFunction() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/script/localFunction.kts"); + doTest(fileName); + } + @TestMetadata("outerCapture.kts") public void testOuterCapture() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/script/outerCapture.kts");