diff --git a/compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInDefault.kt b/compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInDefault.kt new file mode 100644 index 00000000000..16b4745cd82 --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInDefault.kt @@ -0,0 +1,31 @@ +// IGNORE_BACKEND: JVM +// IGNORE_BACKEND_MULTI_MODULE: JVM, JVM_IR +// FILE: 1.kt + +package test + +inline fun myRun(block: () -> T) = block() + +// FILE: 2.kt + +import test.* + +interface IFoo { + fun foo(): String +} + +class A(val x: String, f: () -> IFoo = { + val y = "K" + myRun { + val o = object: IFoo { + override fun foo() = x + y + } + o + } +}) { + val foo: IFoo = f() +} + +fun box(): String { + return A("O").foo.foo() +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFun.kt b/compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFun.kt new file mode 100644 index 00000000000..d41efab287b --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFun.kt @@ -0,0 +1,24 @@ +// IGNORE_BACKEND: JVM +// IGNORE_BACKEND_MULTI_MODULE: JVM, JVM_IR +// FILE: 1.kt + +package test + +inline fun myRun(block: () -> T) = block() + +// FILE: 2.kt + +import test.* + +fun box(): String { + val y = "O" + val x = myRun { + fun foo() = y + "K" + + val o = object { + fun bar() = foo() + } + o + } + return x.bar() +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFunRef.kt b/compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFunRef.kt new file mode 100644 index 00000000000..e637e448eba --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFunRef.kt @@ -0,0 +1,24 @@ +// IGNORE_BACKEND: JVM +// IGNORE_BACKEND_MULTI_MODULE: JVM, JVM_IR +// FILE: 1.kt + +package test + +inline fun myRun(block: () -> T) = block() + +// FILE: 2.kt + +import test.* + +fun box(): String { + val x = myRun { + fun foo() = "OK" + + val o = object { + val f = ::foo + fun bar() = f() + } + o + } + return x.bar() +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/anonymousObject/sharedFromCrossinline.kt b/compiler/testData/codegen/boxInline/anonymousObject/sharedFromCrossinline.kt new file mode 100644 index 00000000000..ca3bfb93949 --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/sharedFromCrossinline.kt @@ -0,0 +1,29 @@ +// FILE: 1.kt + +package test + +inline fun call(crossinline init: () -> Unit) { + return init() +} + +inline fun test(): String { + var res = "Fail" + + call { + object { + fun run () { + res = "OK" + } + }.run() + } + + return res +} + +// FILE: 2.kt + +import test.* + +fun box(): String { + return test() +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/anonymousObject/typeInfo.kt b/compiler/testData/codegen/boxInline/anonymousObject/typeInfo.kt new file mode 100644 index 00000000000..caabd70e017 --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/typeInfo.kt @@ -0,0 +1,14 @@ +// FILE: 1.kt + +package test + +public inline fun foo(block: () -> T) = T::class + +// FILE: 2.kt + +import test.* + +fun box(): String { + foo { object {} } + return "OK" +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index 36d68165187..aa656bb067a 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -41,6 +41,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @TestMetadata("anonymousObjectInDefault.kt") + public void testAnonymousObjectInDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInDefault.kt"); + } + @TestMetadata("anonymousObjectOnCallSite.kt") public void testAnonymousObjectOnCallSite() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnCallSite.kt"); @@ -81,6 +86,16 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLambdaInInlineObject.kt"); } + @TestMetadata("capturedLocalFun.kt") + public void testCapturedLocalFun() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFun.kt"); + } + + @TestMetadata("capturedLocalFunRef.kt") + public void testCapturedLocalFunRef() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFunRef.kt"); + } + @TestMetadata("changingReturnType.kt") public void testChangingReturnType() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); @@ -271,11 +286,21 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/anonymousObject/sam.kt"); } + @TestMetadata("sharedFromCrossinline.kt") + public void testSharedFromCrossinline() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/sharedFromCrossinline.kt"); + } + @TestMetadata("superConstructorWithObjectParameter.kt") public void testSuperConstructorWithObjectParameter() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/superConstructorWithObjectParameter.kt"); } + @TestMetadata("typeInfo.kt") + public void testTypeInfo() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/typeInfo.kt"); + } + @TestMetadata("withInlineMethod.kt") public void testWithInlineMethod() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/withInlineMethod.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index a8a64602428..0654a19a1cc 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -41,6 +41,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @TestMetadata("anonymousObjectInDefault.kt") + public void testAnonymousObjectInDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInDefault.kt"); + } + @TestMetadata("anonymousObjectOnCallSite.kt") public void testAnonymousObjectOnCallSite() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnCallSite.kt"); @@ -81,6 +86,16 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLambdaInInlineObject.kt"); } + @TestMetadata("capturedLocalFun.kt") + public void testCapturedLocalFun() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFun.kt"); + } + + @TestMetadata("capturedLocalFunRef.kt") + public void testCapturedLocalFunRef() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFunRef.kt"); + } + @TestMetadata("changingReturnType.kt") public void testChangingReturnType() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); @@ -271,11 +286,21 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/anonymousObject/sam.kt"); } + @TestMetadata("sharedFromCrossinline.kt") + public void testSharedFromCrossinline() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/sharedFromCrossinline.kt"); + } + @TestMetadata("superConstructorWithObjectParameter.kt") public void testSuperConstructorWithObjectParameter() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/superConstructorWithObjectParameter.kt"); } + @TestMetadata("typeInfo.kt") + public void testTypeInfo() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/typeInfo.kt"); + } + @TestMetadata("withInlineMethod.kt") public void testWithInlineMethod() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/withInlineMethod.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java index 620e48fc5d1..4e37267fa17 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java @@ -41,6 +41,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @TestMetadata("anonymousObjectInDefault.kt") + public void testAnonymousObjectInDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInDefault.kt"); + } + @TestMetadata("anonymousObjectOnCallSite.kt") public void testAnonymousObjectOnCallSite() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnCallSite.kt"); @@ -81,6 +86,16 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLambdaInInlineObject.kt"); } + @TestMetadata("capturedLocalFun.kt") + public void testCapturedLocalFun() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFun.kt"); + } + + @TestMetadata("capturedLocalFunRef.kt") + public void testCapturedLocalFunRef() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFunRef.kt"); + } + @TestMetadata("changingReturnType.kt") public void testChangingReturnType() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); @@ -271,11 +286,21 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/anonymousObject/sam.kt"); } + @TestMetadata("sharedFromCrossinline.kt") + public void testSharedFromCrossinline() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/sharedFromCrossinline.kt"); + } + @TestMetadata("superConstructorWithObjectParameter.kt") public void testSuperConstructorWithObjectParameter() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/superConstructorWithObjectParameter.kt"); } + @TestMetadata("typeInfo.kt") + public void testTypeInfo() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/typeInfo.kt"); + } + @TestMetadata("withInlineMethod.kt") public void testWithInlineMethod() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/withInlineMethod.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index 19f87a6a4a2..b9d70f04179 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -41,6 +41,11 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @TestMetadata("anonymousObjectInDefault.kt") + public void testAnonymousObjectInDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInDefault.kt"); + } + @TestMetadata("anonymousObjectOnCallSite.kt") public void testAnonymousObjectOnCallSite() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnCallSite.kt"); @@ -81,6 +86,16 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLambdaInInlineObject.kt"); } + @TestMetadata("capturedLocalFun.kt") + public void testCapturedLocalFun() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFun.kt"); + } + + @TestMetadata("capturedLocalFunRef.kt") + public void testCapturedLocalFunRef() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFunRef.kt"); + } + @TestMetadata("changingReturnType.kt") public void testChangingReturnType() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); @@ -271,11 +286,21 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTest("compiler/testData/codegen/boxInline/anonymousObject/sam.kt"); } + @TestMetadata("sharedFromCrossinline.kt") + public void testSharedFromCrossinline() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/sharedFromCrossinline.kt"); + } + @TestMetadata("superConstructorWithObjectParameter.kt") public void testSuperConstructorWithObjectParameter() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/superConstructorWithObjectParameter.kt"); } + @TestMetadata("typeInfo.kt") + public void testTypeInfo() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/typeInfo.kt"); + } + @TestMetadata("withInlineMethod.kt") public void testWithInlineMethod() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/withInlineMethod.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java index c688bfe5db4..f1c2df3b849 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java @@ -41,6 +41,11 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + @TestMetadata("anonymousObjectInDefault.kt") + public void testAnonymousObjectInDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInDefault.kt"); + } + @TestMetadata("anonymousObjectOnCallSite.kt") public void testAnonymousObjectOnCallSite() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnCallSite.kt"); @@ -81,6 +86,16 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLambdaInInlineObject.kt"); } + @TestMetadata("capturedLocalFun.kt") + public void testCapturedLocalFun() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFun.kt"); + } + + @TestMetadata("capturedLocalFunRef.kt") + public void testCapturedLocalFunRef() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFunRef.kt"); + } + @TestMetadata("changingReturnType.kt") public void testChangingReturnType() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); @@ -246,11 +261,21 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes runTest("compiler/testData/codegen/boxInline/anonymousObject/safeCall_2.kt"); } + @TestMetadata("sharedFromCrossinline.kt") + public void testSharedFromCrossinline() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/sharedFromCrossinline.kt"); + } + @TestMetadata("superConstructorWithObjectParameter.kt") public void testSuperConstructorWithObjectParameter() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/superConstructorWithObjectParameter.kt"); } + @TestMetadata("typeInfo.kt") + public void testTypeInfo() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/typeInfo.kt"); + } + @TestMetadata("withInlineMethod.kt") public void testWithInlineMethod() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/withInlineMethod.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java index 2fd51a1f639..838caab5c14 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java @@ -41,6 +41,11 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } + @TestMetadata("anonymousObjectInDefault.kt") + public void testAnonymousObjectInDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInDefault.kt"); + } + @TestMetadata("anonymousObjectOnCallSite.kt") public void testAnonymousObjectOnCallSite() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnCallSite.kt"); @@ -81,6 +86,16 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLambdaInInlineObject.kt"); } + @TestMetadata("capturedLocalFun.kt") + public void testCapturedLocalFun() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFun.kt"); + } + + @TestMetadata("capturedLocalFunRef.kt") + public void testCapturedLocalFunRef() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/capturedLocalFunRef.kt"); + } + @TestMetadata("changingReturnType.kt") public void testChangingReturnType() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); @@ -246,11 +261,21 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { runTest("compiler/testData/codegen/boxInline/anonymousObject/safeCall_2.kt"); } + @TestMetadata("sharedFromCrossinline.kt") + public void testSharedFromCrossinline() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/sharedFromCrossinline.kt"); + } + @TestMetadata("superConstructorWithObjectParameter.kt") public void testSuperConstructorWithObjectParameter() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/superConstructorWithObjectParameter.kt"); } + @TestMetadata("typeInfo.kt") + public void testTypeInfo() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/typeInfo.kt"); + } + @TestMetadata("withInlineMethod.kt") public void testWithInlineMethod() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/withInlineMethod.kt");