diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 018b0c8519b..713269121e5 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -18457,6 +18457,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt"); } + @Test + @TestMetadata("possibleOverrideClash.kt") + public void testPossibleOverrideClash() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/possibleOverrideClash.kt"); + } + @Test @TestMetadata("primitiveVsWrapperInSam.kt") public void testPrimitiveVsWrapperInSam() throws Exception { @@ -18499,6 +18505,40 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/suspendFunInterface.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inline") + @TestDataPath("$PROJECT_ROOT") + public class Inline extends AbstractFirBlackBoxCodegenTest { + @Test + public void testAllFilesPresentInInline() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("crossinlineLambda1.kt") + public void testCrossinlineLambda1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/crossinlineLambda1.kt"); + } + + @Test + @TestMetadata("crossinlineLambda2.kt") + public void testCrossinlineLambda2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/crossinlineLambda2.kt"); + } + + @Test + @TestMetadata("inlineFunInDifferentPackage.kt") + public void testInlineFunInDifferentPackage() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/inlineFunInDifferentPackage.kt"); + } + + @Test + @TestMetadata("inlineLambda1.kt") + public void testInlineLambda1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/inlineLambda1.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @@ -18580,28 +18620,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/genericFunInterfaceWithInlineString.kt"); } } - - @Nested - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineContext") - @TestDataPath("$PROJECT_ROOT") - public class InlineContext extends AbstractFirBlackBoxCodegenTest { - @Test - public void testAllFilesPresentInInlineContext() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineContext"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("inlineFunInDifferentPackage.kt") - public void testInlineFunInDifferentPackage() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineContext/inlineFunInDifferentPackage.kt"); - } - - @Test - @TestMetadata("inlineLambda1.kt") - public void testInlineLambda1() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineContext/inlineLambda1.kt"); - } - } } } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FakeInliningLocalVariablesLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FakeInliningLocalVariablesLowering.kt index 1393c400322..95a60e2d392 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FakeInliningLocalVariablesLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FakeInliningLocalVariablesLowering.kt @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.IrBlockBody import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.ir.expressions.IrFunctionReference +import org.jetbrains.kotlin.ir.util.dump import org.jetbrains.kotlin.load.java.JvmAbi internal val fakeInliningLocalVariablesLowering = makeIrFilePhase( @@ -56,16 +57,22 @@ internal class FakeInliningLocalVariablesLowering(val context: JvmBackendContext } private fun IrFunction.addFakeLocalVariable(name: String) { + val oldBody = body context.createIrBuilder(symbol).run { body = irBlockBody { // Create temporary variable, but make sure it's origin is `DEFINED` so that // it will materialize in the code. // Also, do not forget to remove $$forInline suffix, otherwise, IDE will not be able to navigate to inline function. createTmpVariable(irInt(0), name.removeSuffix(FOR_INLINE_SUFFIX), origin = IrDeclarationOrigin.DEFINED) - if (body is IrExpressionBody) { - +irReturn((body as IrExpressionBody).expression) - } else { - (body as IrBlockBody).statements.forEach { +it } + when (oldBody) { + is IrExpressionBody -> { + +irReturn(oldBody.expression) + } + is IrBlockBody -> + oldBody.statements.forEach { +it } + else -> { + throw AssertionError("Unexpected body:\n${this@addFakeLocalVariable.dump()}") + } } } } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt index 4654ddf6dc5..84c43490af6 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt @@ -45,6 +45,8 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) // function reference classes needed. private val ignoredFunctionReferences = mutableSetOf>() + private val inlineLambdaToValueParameter = HashMap() + private val IrFunctionReference.isIgnored: Boolean get() = (!type.isFunctionOrKFunction() && !isSuspendFunctionReference()) || ignoredFunctionReferences.contains(this) @@ -56,7 +58,20 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) (origin == null || origin == IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE || origin == IrStatementOrigin.SUSPEND_CONVERSION) override fun lower(irFile: IrFile) { - ignoredFunctionReferences.addAll(IrInlineReferenceLocator.scan(context, irFile)) + irFile.accept( + object : IrInlineReferenceLocator(context) { + override fun visitInlineLambda( + argument: IrFunctionReference, + callee: IrFunction, + parameter: IrValueParameter, + scope: IrDeclaration + ) { + ignoredFunctionReferences.add(argument) + inlineLambdaToValueParameter[argument.symbol.owner] = parameter + } + }, + null + ) irFile.transformChildrenVoid(this) } @@ -137,12 +152,21 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) return false // Can't use indy-based SAM conversion inside inline fun (Ok in inline lambda). - if (target.parents.any { it is IrSimpleFunction && it.isInline && it.origin != IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA }) + if (target.parents.any { it.isInlineFunction() || it.isCrossinlineLambda() }) return false return true } + private fun IrDeclarationParent.isInlineFunction() = + this is IrSimpleFunction && isInline && origin != IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA + + private fun IrDeclarationParent.isCrossinlineLambda(): Boolean { + val irFun = this as? IrSimpleFunction ?: return false + return origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA && + inlineLambdaToValueParameter[irFun]?.isCrossinline == true + } + private fun IrType.isProhibitedTypeForIndySamConversion(): Boolean { if (this !is IrSimpleType) return false diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt index b2f51286227..c20f7f72cfd 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt @@ -221,6 +221,7 @@ private fun IrSimpleFunction.createMultifileDelegateIfNeeded( if (DescriptorVisibilities.isPrivate(originalVisibility) || name == StaticInitializersLowering.clinitName || origin == JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR || + origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA || // $annotations methods in the facade are only needed for const properties. (origin == JvmLoweredDeclarationOrigin.SYNTHETIC_METHOD_FOR_PROPERTY_OR_TYPEALIAS_ANNOTATIONS && (metadata as? MetadataSource.Property)?.isConst != true) diff --git a/compiler/testData/codegen/box/invokedynamic/sam/inline/crossinlineLambda1.kt b/compiler/testData/codegen/box/invokedynamic/sam/inline/crossinlineLambda1.kt new file mode 100644 index 00000000000..21e8936805c --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/inline/crossinlineLambda1.kt @@ -0,0 +1,20 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: 1.kt +inline fun cross(crossinline fn: () -> String) : Any = + object { + override fun toString(): String = fn() + } + +fun interface IFoo { + fun foo(): String +} + +fun foo(iFoo: IFoo) = iFoo.foo() + +// FILE: 2.kt +fun box() = + cross { + foo { "OK" } + }.toString() \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/inline/crossinlineLambda2.kt b/compiler/testData/codegen/box/invokedynamic/sam/inline/crossinlineLambda2.kt new file mode 100644 index 00000000000..fa184cf4d9a --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/inline/crossinlineLambda2.kt @@ -0,0 +1,26 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: 1.kt +class C { + fun test() = + cross { + foo { "OK" } + }.toString() +} + +inline fun cross(crossinline fn: () -> String) : Any = + object { + override fun toString(): String = fn() + } + +fun interface IFoo { + fun foo(): String +} + +fun foo(iFoo: IFoo) = iFoo.foo() + +// FILE: 2.kt +fun box() = + C().test() + diff --git a/compiler/testData/codegen/box/invokedynamic/sam/inlineContext/inlineFunInDifferentPackage.kt b/compiler/testData/codegen/box/invokedynamic/sam/inline/inlineFunInDifferentPackage.kt similarity index 85% rename from compiler/testData/codegen/box/invokedynamic/sam/inlineContext/inlineFunInDifferentPackage.kt rename to compiler/testData/codegen/box/invokedynamic/sam/inline/inlineFunInDifferentPackage.kt index df4a44b7b64..29b1ef040c9 100644 --- a/compiler/testData/codegen/box/invokedynamic/sam/inlineContext/inlineFunInDifferentPackage.kt +++ b/compiler/testData/codegen/box/invokedynamic/sam/inline/inlineFunInDifferentPackage.kt @@ -2,12 +2,12 @@ // JVM_TARGET: 1.8 // SAM_CONVERSIONS: INDY // WITH_RUNTIME -// FILE: inlineFunInDifferentPackage.kt +// FILE: 2.kt import a.* fun box() = test { k -> "O" + k } -// FILE: a.kt +// FILE: 1.kt package a fun interface IFoo { diff --git a/compiler/testData/codegen/box/invokedynamic/sam/inlineContext/inlineLambda1.kt b/compiler/testData/codegen/box/invokedynamic/sam/inline/inlineLambda1.kt similarity index 92% rename from compiler/testData/codegen/box/invokedynamic/sam/inlineContext/inlineLambda1.kt rename to compiler/testData/codegen/box/invokedynamic/sam/inline/inlineLambda1.kt index 47d7f8411ea..d025660c159 100644 --- a/compiler/testData/codegen/box/invokedynamic/sam/inlineContext/inlineLambda1.kt +++ b/compiler/testData/codegen/box/invokedynamic/sam/inline/inlineLambda1.kt @@ -2,6 +2,7 @@ // JVM_TARGET: 1.8 // SAM_CONVERSIONS: INDY // WITH_RUNTIME +// FILE: 1.kt fun interface IFoo { fun foo() } @@ -13,6 +14,7 @@ inline fun twice(fn: () -> Unit) { fn() } +// FILE: 2.kt fun box(): String { var test = 0 twice { diff --git a/compiler/testData/codegen/box/invokedynamic/sam/possibleOverrideClash.kt b/compiler/testData/codegen/box/invokedynamic/sam/possibleOverrideClash.kt new file mode 100644 index 00000000000..4220b4aa931 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/possibleOverrideClash.kt @@ -0,0 +1,19 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +fun interface IFoo { + fun foo(): String +} + +fun foo(iFoo: IFoo) = iFoo.foo() + +open class C1 { + open fun test() = foo { "O" } +} + +class C2 : C1() { + override fun test() = foo { "K" } +} + +fun box() = + C1().test() + C2().test() diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index fab16cfd3bb..2bd48b10080 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -18457,6 +18457,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt"); } + @Test + @TestMetadata("possibleOverrideClash.kt") + public void testPossibleOverrideClash() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/possibleOverrideClash.kt"); + } + @Test @TestMetadata("primitiveVsWrapperInSam.kt") public void testPrimitiveVsWrapperInSam() throws Exception { @@ -18499,6 +18505,40 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/suspendFunInterface.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inline") + @TestDataPath("$PROJECT_ROOT") + public class Inline extends AbstractBlackBoxCodegenTest { + @Test + public void testAllFilesPresentInInline() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("crossinlineLambda1.kt") + public void testCrossinlineLambda1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/crossinlineLambda1.kt"); + } + + @Test + @TestMetadata("crossinlineLambda2.kt") + public void testCrossinlineLambda2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/crossinlineLambda2.kt"); + } + + @Test + @TestMetadata("inlineFunInDifferentPackage.kt") + public void testInlineFunInDifferentPackage() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/inlineFunInDifferentPackage.kt"); + } + + @Test + @TestMetadata("inlineLambda1.kt") + public void testInlineLambda1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/inlineLambda1.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @@ -18580,28 +18620,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/genericFunInterfaceWithInlineString.kt"); } } - - @Nested - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineContext") - @TestDataPath("$PROJECT_ROOT") - public class InlineContext extends AbstractBlackBoxCodegenTest { - @Test - public void testAllFilesPresentInInlineContext() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineContext"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("inlineFunInDifferentPackage.kt") - public void testInlineFunInDifferentPackage() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineContext/inlineFunInDifferentPackage.kt"); - } - - @Test - @TestMetadata("inlineLambda1.kt") - public void testInlineLambda1() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineContext/inlineLambda1.kt"); - } - } } } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index f9254bc5b6d..a31d49d27ae 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -18457,6 +18457,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt"); } + @Test + @TestMetadata("possibleOverrideClash.kt") + public void testPossibleOverrideClash() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/possibleOverrideClash.kt"); + } + @Test @TestMetadata("primitiveVsWrapperInSam.kt") public void testPrimitiveVsWrapperInSam() throws Exception { @@ -18499,6 +18505,40 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/suspendFunInterface.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inline") + @TestDataPath("$PROJECT_ROOT") + public class Inline extends AbstractIrBlackBoxCodegenTest { + @Test + public void testAllFilesPresentInInline() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("crossinlineLambda1.kt") + public void testCrossinlineLambda1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/crossinlineLambda1.kt"); + } + + @Test + @TestMetadata("crossinlineLambda2.kt") + public void testCrossinlineLambda2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/crossinlineLambda2.kt"); + } + + @Test + @TestMetadata("inlineFunInDifferentPackage.kt") + public void testInlineFunInDifferentPackage() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/inlineFunInDifferentPackage.kt"); + } + + @Test + @TestMetadata("inlineLambda1.kt") + public void testInlineLambda1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/inlineLambda1.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @@ -18580,28 +18620,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/genericFunInterfaceWithInlineString.kt"); } } - - @Nested - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineContext") - @TestDataPath("$PROJECT_ROOT") - public class InlineContext extends AbstractIrBlackBoxCodegenTest { - @Test - public void testAllFilesPresentInInlineContext() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineContext"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("inlineFunInDifferentPackage.kt") - public void testInlineFunInDifferentPackage() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineContext/inlineFunInDifferentPackage.kt"); - } - - @Test - @TestMetadata("inlineLambda1.kt") - public void testInlineLambda1() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineContext/inlineLambda1.kt"); - } - } } } diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 02a38cf4c29..1253e91d528 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -16183,6 +16183,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt"); } + @TestMetadata("possibleOverrideClash.kt") + public void testPossibleOverrideClash() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/possibleOverrideClash.kt"); + } + @TestMetadata("primitiveVsWrapperInSam.kt") public void testPrimitiveVsWrapperInSam() throws Exception { runTest("compiler/testData/codegen/box/invokedynamic/sam/primitiveVsWrapperInSam.kt"); @@ -16218,6 +16223,39 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/suspendFunInterface.kt"); } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inline") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Inline extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInInline() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("crossinlineLambda1.kt") + public void testCrossinlineLambda1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/crossinlineLambda1.kt"); + } + + @TestMetadata("crossinlineLambda2.kt") + public void testCrossinlineLambda2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/crossinlineLambda2.kt"); + } + + @TestMetadata("inlineFunInDifferentPackage.kt") + public void testInlineFunInDifferentPackage() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/inlineFunInDifferentPackage.kt"); + } + + @TestMetadata("inlineLambda1.kt") + public void testInlineLambda1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/inline/inlineLambda1.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -16290,29 +16328,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/genericFunInterfaceWithInlineString.kt"); } } - - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineContext") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class InlineContext extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInInlineContext() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineContext"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("inlineFunInDifferentPackage.kt") - public void testInlineFunInDifferentPackage() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineContext/inlineFunInDifferentPackage.kt"); - } - - @TestMetadata("inlineLambda1.kt") - public void testInlineLambda1() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineContext/inlineLambda1.kt"); - } - } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 81156d68bfe..21993b93b26 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -13903,6 +13903,19 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inline") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Inline extends AbstractIrJsCodegenBoxES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInInline() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -13915,19 +13928,6 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } } - - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineContext") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class InlineContext extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInInlineContext() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineContext"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 949f18a22be..b947ffc7c3d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -13903,6 +13903,19 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inline") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Inline extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInInline() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -13915,19 +13928,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } } - - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineContext") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class InlineContext extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInInlineContext() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineContext"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index af9a372d26b..85bb3588fd6 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -13968,6 +13968,19 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inline") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Inline extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInInline() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -13980,19 +13993,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } } - - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineContext") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class InlineContext extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInInlineContext() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineContext"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index d464975739d..94605af3d16 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -8064,6 +8064,19 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inline") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Inline extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInInline() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inline"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -8076,19 +8089,6 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } } - - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineContext") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class InlineContext extends AbstractIrCodegenBoxWasmTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); - } - - public void testAllFilesPresentInInlineContext() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineContext"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); - } - } } }