From 741c1a864f2dadfa0c8a19f31f2d6048b7d6cb89 Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Tue, 16 Feb 2021 09:24:49 +0100 Subject: [PATCH] JVM_IR: IC: Unbox inline class argument of callable reference if it is unbound and the underlying type is reference type. If the underlying type is primitive, it is boxed and unboxed correctly, otherwise, it is simply casted and not unboxed. Additionally, generate functions for inliner with inline classes in signature, so unboxing works. The unboxing is removed after inlining. #KT-44722 Fixed --- .../FirBlackBoxCodegenTestGenerated.java | 52 +++++++++++++++++++ .../backend/jvm/codegen/ExpressionCodegen.kt | 15 ++++++ .../jvm/codegen/MethodSignatureMapper.kt | 31 ++++++++--- .../jvm/lower/inlineclasses/InlineClassAbi.kt | 8 +++ ...CallableReferencePassedToInlineFunction.kt | 4 +- .../callableReferences/let/any.kt | 22 ++++++++ .../callableReferences/let/anyN.kt | 22 ++++++++ .../callableReferences/let/int.kt | 24 +++++++++ .../callableReferences/let/intN.kt | 24 +++++++++ .../callableReferences/let/result.kt | 23 ++++++++ .../callableReferences/let/string.kt | 22 ++++++++ .../callableReferences/let/stringN.kt | 22 ++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 52 +++++++++++++++++++ .../IrBlackBoxCodegenTestGenerated.java | 52 +++++++++++++++++++ .../LightAnalysisModeTestGenerated.java | 48 +++++++++++++++++ .../IrJsCodegenBoxES6TestGenerated.java | 48 +++++++++++++++++ .../IrJsCodegenBoxTestGenerated.java | 48 +++++++++++++++++ .../semantics/JsCodegenBoxTestGenerated.java | 48 +++++++++++++++++ .../IrCodegenBoxWasmTestGenerated.java | 48 +++++++++++++++++ 19 files changed, 604 insertions(+), 9 deletions(-) create mode 100644 compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index af7a523537f..af28c640ed0 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -18214,6 +18214,58 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + public class Let { + @Test + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @Test + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @Test + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @Test + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @Test + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @Test + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @Test + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @Nested diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 11790f03c22..0aa7333d22b 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -15,6 +15,8 @@ import org.jetbrains.kotlin.backend.jvm.ir.erasedUpperBound import org.jetbrains.kotlin.backend.jvm.ir.isFromJava import org.jetbrains.kotlin.backend.jvm.lower.MultifileFacadeFileEntry import org.jetbrains.kotlin.backend.jvm.lower.constantValue +import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.isInlineCallableReference +import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.isMappedToPrimitive import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.unboxInlineClass import org.jetbrains.kotlin.backend.jvm.lower.isMultifileBridge import org.jetbrains.kotlin.backend.jvm.lower.suspendFunctionOriginal @@ -625,14 +627,27 @@ class ExpressionCodegen( val type = frameMap.typeOf(expression.symbol) mv.load(findLocalIndex(expression.symbol), type) unboxResultIfNeeded(expression) + unboxInlineClassArgumentOfInlineCallableReference(expression) return MaterialValue(this, type, expression.type) } + // JVM_IR generates inline callable differently from the old backend: + // it generates them as normal functions and not objects. + // Thus, we need to unbox inline class argument with reference underlying type. + private fun unboxInlineClassArgumentOfInlineCallableReference(arg: IrGetValue) { + if (!arg.type.isInlined()) return + if (arg.type.isMappedToPrimitive) return + if (!irFunction.isInlineCallableReference) return + if (irFunction.extensionReceiverParameter?.symbol == arg.symbol) return + StackValue.unboxInlineClass(OBJECT_TYPE, arg.type.erasedUpperBound.defaultType.toIrBasedKotlinType(), mv) + } + // We do not mangle functions if Result is the only parameter of the function, // thus, if the function overrides generic parameter, its argument is boxed and there is no // bridge to unbox it. Instead, we unbox it in the non-mangled function manually. private fun unboxResultIfNeeded(arg: IrGetValue) { if (arg.type.erasedUpperBound.fqNameWhenAvailable != StandardNames.RESULT_FQ_NAME) return + // Do not unbox arguments of lambda, but unbox arguments of callable references if (irFunction.origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA) return if (!onlyResultInlineClassParameters()) return if (irFunction !is IrSimpleFunction) return diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt index bc16a88365f..c885a659577 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt @@ -12,6 +12,8 @@ import org.jetbrains.kotlin.backend.common.lower.parentsWithSelf import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.ir.* +import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.isInlineCallableReference +import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.isMappedToPrimitive import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.unboxInlineClass import org.jetbrains.kotlin.backend.jvm.lower.suspendFunctionOriginal import org.jetbrains.kotlin.builtins.StandardNames @@ -60,7 +62,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { fun mapFieldSignature(field: IrField): String? { val sw = BothSignatureWriter(BothSignatureWriter.Mode.TYPE) if (field.correspondingPropertySymbol?.owner?.isVar == true) { - writeParameterType(sw, field.type, field) + writeParameterType(sw, field.type, field, false) } else { mapReturnType(field, field.type, sw) } @@ -219,6 +221,13 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { function.origin == JvmLoweredDeclarationOrigin.SYNTHETIC_INLINE_CLASS_MEMBER && function.name.asString() == "box-impl" + private fun forceBoxedInlineClassParametersForInliner(function: IrDeclaration, type: IrType, isBoundReceiver: Boolean): Boolean { + if (isBoundReceiver) return false + if (function !is IrSimpleFunction) return false + if (!function.isInlineCallableReference) return false + return type.isInlined() && !type.isMappedToPrimitive + } + fun mapSignatureSkipGeneric(function: IrFunction): JvmMethodSignature = mapSignature(function, true) @@ -243,7 +252,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { val receiverParameter = function.extensionReceiverParameter if (receiverParameter != null) { - writeParameter(sw, JvmMethodParameterKind.RECEIVER, receiverParameter.type, function) + writeParameter(sw, JvmMethodParameterKind.RECEIVER, receiverParameter.type, function, true) } for (parameter in function.valueParameters) { @@ -256,7 +265,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { if (shouldBoxSingleValueParameterForSpecialCaseOfRemove(function)) parameter.type.makeNullable() else parameter.type - writeParameter(sw, kind, type, function) + writeParameter(sw, kind, type, function, parameter.symbol == function.extensionReceiverParameter?.symbol) } sw.writeReturnType() @@ -318,15 +327,23 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { return irFunction.allOverridden(false).any { it.parent.kotlinFqName == StandardNames.FqNames.mutableCollection } } - private fun writeParameter(sw: JvmSignatureWriter, kind: JvmMethodParameterKind, type: IrType, function: IrFunction) { + private fun writeParameter( + sw: JvmSignatureWriter, + kind: JvmMethodParameterKind, + type: IrType, + function: IrFunction, + isReceiver: Boolean + ) { sw.writeParameterType(kind) - writeParameterType(sw, type, function) + writeParameterType(sw, type, function, isReceiver) sw.writeParameterTypeEnd() } - private fun writeParameterType(sw: JvmSignatureWriter, type: IrType, declaration: IrDeclaration) { + private fun writeParameterType(sw: JvmSignatureWriter, type: IrType, declaration: IrDeclaration, isReceiver: Boolean) { if (sw.skipGenericSignature()) { - if (type.isInlined() && declaration.isFromJava()) { + if (type.isInlined() && + (declaration.isFromJava() || forceBoxedInlineClassParametersForInliner(declaration, type, isReceiver)) + ) { typeMapper.mapType(type, TypeMappingMode.GENERIC_ARGUMENT, sw) } else { typeMapper.mapType(type, TypeMappingMode.DEFAULT, sw) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt index 8ffab3c343f..37e39052d9e 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt @@ -166,3 +166,11 @@ val IrFunction.isInlineClassFieldGetter: Boolean val IrFunction.isPrimaryInlineClassConstructor: Boolean get() = this is IrConstructor && isPrimary && constructedClass.isInline + +val IrFunction.isInlineCallableReference: Boolean + get() = origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA && name.asString().contains("\$stub_for_inlining") + +val IrType.isMappedToPrimitive: Boolean + get() = isInlined() && + !(isNullable() && makeNotNull().unboxInlineClass().isNullable()) && + makeNotNull().unboxInlineClass().isPrimitiveType() \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt b/compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt index 2843b975a31..bdb86ee439d 100644 --- a/compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt +++ b/compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt @@ -54,11 +54,11 @@ fun box(): String { val a = IcAny(5) val o = IcOverIc(IcLong(6)) - if (testUnboxed(i, l, a, o) != "345IcLong(l=6)") return "Fail 1" + if (testUnboxed(i, l, a, o) != "345IcLong(l=6)") return "Fail 1 ${testUnboxed(i, l, a, o)}" if (testBoxed(i, l, a, o) != "345IcLong(l=6)") return "Fail 2" if (testLocalVars() != "012IcLong(l=3)") return "Fail 3" if (testGlobalProperties() != "123IcLong(l=4)") return "Fail 4" - if (testCapturedVars() != "234IcLong(l=5)") return "Fail 5" + if (testCapturedVars() != "234IcLong(l=5)") return "Fail 5 ${testCapturedVars()}" return "OK" } diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt new file mode 100644 index 00000000000..1e68b5d1782 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt @@ -0,0 +1,22 @@ +inline class Value(val value: Any) + +object Foo { + fun foo(value: Value) { + res = value.value as String + } + + fun bar(value: Value?) { + res = value?.value as String + } +} + +var res = "FAIL" + +fun box(): String { + Value("OK").let(Foo::foo) + if (res != "OK") return "FAIL 1: $res" + res = "FAIL" + + Value("OK").let(Foo::bar) + return res +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt new file mode 100644 index 00000000000..baba06fb8bb --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt @@ -0,0 +1,22 @@ +inline class Value(val value: Any?) + +object Foo { + fun foo(value: Value) { + res = value.value as String + } + + fun bar(value: Value?) { + res = value?.value as String + } +} + +var res = "FAIL" + +fun box(): String { + Value("OK").let(Foo::foo) + if (res != "OK") return "FAIL 1: $res" + res = "FAIL" + + Value("OK").let(Foo::bar) + return res +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt new file mode 100644 index 00000000000..b1e80d89ed0 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt @@ -0,0 +1,24 @@ +inline class Value(val value: Int) + +object Foo { + fun foo(value: Value) { + res = value.value + } + + fun bar(value: Value?) { + res = value?.value!! + } +} + +var res = 0 + +fun box(): String { + Value(42).let(Foo::foo) + if (res != 42) return "FAIL 1 $res" + res = 0 + + Value(42).let(Foo::bar) + if (res != 42) return "FAIL 2 $res" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt new file mode 100644 index 00000000000..cbb86d633f6 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt @@ -0,0 +1,24 @@ +inline class Value(val value: Int?) + +object Foo { + fun foo(value: Value) { + res = value.value!! + } + + fun bar(value: Value?) { + res = value?.value!! + } +} + +var res = 0 + +fun box(): String { + Value(42).let(Foo::foo) + if (res != 42) return "FAIL 1 $res" + res = 0 + + Value(42).let(Foo::bar) + if (res != 42) return "FAIL 2 $res" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt new file mode 100644 index 00000000000..70021248e67 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt @@ -0,0 +1,23 @@ +// WITH_RUNTIME +// KJS_WITH_FULL_RUNTIME + +object Foo { + fun foo(result: Result) { + res = result.getOrNull()!! + } + + fun bar(result: Result?) { + res = result?.getOrNull()!! + } +} + +var res = "FAIL" + +fun box(): String { + Result.success("OK").let(Foo::foo) + if (res != "OK") return "FAIL 1 $res" + res = "FAIL" + + Result.success("OK").let(Foo::bar) + return res +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt new file mode 100644 index 00000000000..f28dba61fd6 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt @@ -0,0 +1,22 @@ +inline class Value(val value: String) + +object Foo { + fun foo(value: Value) { + res = value.value + } + + fun bar(value: Value?) { + res = value?.value!! + } +} + +var res = "FAIL" + +fun box(): String { + Value("OK").let(Foo::foo) + if (res != "OK") return "FAIL 1: $res" + res = "FAIL" + + Value("OK").let(Foo::bar) + return res +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt new file mode 100644 index 00000000000..5a66c2a727a --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt @@ -0,0 +1,22 @@ +inline class Value(val value: String?) + +object Foo { + fun foo(value: Value) { + res = value.value!! + } + + fun bar(value: Value?) { + res = value?.value!! + } +} + +var res = "FAIL" + +fun box(): String { + Value("OK").let(Foo::foo) + if (res != "OK") return "FAIL 1: $res" + res = "FAIL" + + Value("OK").let(Foo::bar) + return res +} \ No newline at end of file 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 a636d7b31ba..c05ea81c681 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 @@ -18214,6 +18214,58 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + public class Let { + @Test + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @Test + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @Test + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @Test + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @Test + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @Test + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @Test + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @Nested 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 11d91fb81ae..74aeafa291a 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 @@ -18214,6 +18214,58 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + public class Let { + @Test + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @Test + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @Test + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @Test + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @Test + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @Test + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @Test + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @Nested diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 09a84c914c0..640a8f49110 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -15168,6 +15168,54 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Let extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors") 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 491dcd822bb..9c44c09e21d 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 @@ -13343,6 +13343,54 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Let extends AbstractIrJsCodegenBoxES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors") 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 fda916303a0..bae8d522aad 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 @@ -12828,6 +12828,54 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Let extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors") 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 67e5a2ac3f2..e2ae4ca6ee8 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 @@ -12893,6 +12893,54 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Let extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors") 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 6a54105c50d..15b59cf2c7b 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 @@ -7089,6 +7089,54 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Let extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors")