diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java index 78cc475b292..c9b99edc41d 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java @@ -1020,6 +1020,46 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn runTest("compiler/testData/codegen/boxInline/callableReference/topLevelProperty.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/boxInline/callableReference/adaptedReferences") + @TestDataPath("$PROJECT_ROOT") + public class AdaptedReferences { + @Test + public void testAllFilesPresentInAdaptedReferences() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/callableReference/adaptedReferences"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineBound.kt"); + } + + @Test + @TestMetadata("inlineDefault.kt") + public void testInlineDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineDefault.kt"); + } + + @Test + @TestMetadata("inlineVararg.kt") + public void testInlineVararg() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVararg.kt"); + } + + @Test + @TestMetadata("inlineVarargAndDefault.kt") + public void testInlineVarargAndDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargAndDefault.kt"); + } + + @Test + @TestMetadata("inlineVarargInts.kt") + public void testInlineVarargInts() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargInts.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/boxInline/callableReference/bound") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt index 1a29f8e91c9..0691b6792c5 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt @@ -225,8 +225,6 @@ class FunctionInlining( else (copyIrElement.copy(argument) as IrExpression) } - //-----------------------------------------------------------------// - override fun visitCall(expression: IrCall): IrExpression { if (!isLambdaCall(expression)) return super.visitCall(expression) @@ -236,119 +234,133 @@ class FunctionInlining( if ((dispatchReceiver.symbol.owner as? IrValueParameter)?.isNoinline == true) return super.visitCall(expression) - if (functionArgument is IrFunctionReference) { - functionArgument.transformChildrenVoid(this) - - val function = functionArgument.symbol.owner - val functionParameters = function.explicitParameters - val boundFunctionParameters = functionArgument.getArgumentsWithIr() - val unboundFunctionParameters = functionParameters - boundFunctionParameters.map { it.first } - val boundFunctionParametersMap = boundFunctionParameters.associate { it.first to it.second } - - var unboundIndex = 0 - val unboundArgsSet = unboundFunctionParameters.toSet() - val valueParameters = expression.getArgumentsWithIr().drop(1) // Skip dispatch receiver. - - val superType = functionArgument.type as IrSimpleType - val superTypeArgumentsMap = expression.symbol.owner.parentAsClass.typeParameters.associate { typeParam -> - typeParam.symbol to superType.arguments[typeParam.index].typeOrNull!! - } - - val immediateCall = with(expression) { - when (function) { - is IrConstructor -> { - val classTypeParametersCount = function.parentAsClass.typeParameters.size - IrConstructorCallImpl.fromSymbolOwner( - startOffset, - endOffset, - function.returnType, - function.symbol, - classTypeParametersCount - ) - } - is IrSimpleFunction -> - IrCallImpl( - startOffset, - endOffset, - function.returnType, - function.symbol, - function.typeParameters.size, - function.valueParameters.size - ) - else -> - error("Unknown function kind : ${function.render()}") - } - }.apply { - for (parameter in functionParameters) { - val argument = - if (parameter !in unboundArgsSet) { - val arg = boundFunctionParametersMap[parameter]!! - if (arg is IrGetValueWithoutLocation) - arg.withLocation(expression.startOffset, expression.endOffset) - else arg - } else { - if (unboundIndex == valueParameters.size && parameter.defaultValue != null) - copyIrElement.copy(parameter.defaultValue!!.expression) as IrExpression - else if (!parameter.isVararg) { - assert(unboundIndex < valueParameters.size) { - "Attempt to use unbound parameter outside of the callee's value parameters" - } - valueParameters[unboundIndex++].second - } else { - val elements = mutableListOf() - while (unboundIndex < valueParameters.size) { - val (param, value) = valueParameters[unboundIndex++] - val substitutedParamType = param.type.substitute(superTypeArgumentsMap) - if (substitutedParamType == parameter.varargElementType!!) - elements += value - else - elements += IrSpreadElementImpl(expression.startOffset, expression.endOffset, value) - } - IrVarargImpl( - expression.startOffset, expression.endOffset, - parameter.type, - parameter.varargElementType!!, - elements - ) - } - } - when (parameter) { - function.dispatchReceiverParameter -> - this.dispatchReceiver = argument.implicitCastIfNeededTo(function.dispatchReceiverParameter!!.type) - - function.extensionReceiverParameter -> - this.extensionReceiver = argument.implicitCastIfNeededTo(function.extensionReceiverParameter!!.type) - - else -> - putValueArgument( - parameter.index, - argument.implicitCastIfNeededTo(function.valueParameters[parameter.index].type) - ) - } - } - assert(unboundIndex == valueParameters.size) { "Not all arguments of the callee are used" } - for (index in 0 until functionArgument.typeArgumentsCount) - putTypeArgument(index, functionArgument.getTypeArgument(index)) - }.implicitCastIfNeededTo(expression.type) - return this@FunctionInlining.visitExpression(super.visitExpression(immediateCall)) + return when { + functionArgument is IrFunctionReference -> inlineFunctionReference(expression, functionArgument) + functionArgument.isAdaptedFunctionReference() -> inlineAdaptedFunctionReference(expression, functionArgument as IrBlock) + functionArgument is IrFunctionExpression -> inlineFunctionExpression(expression, functionArgument) + else -> super.visitCall(expression) } - if (functionArgument !is IrFunctionExpression) - return super.visitCall(expression) + } + fun inlineFunctionExpression(irCall: IrCall, irFunctionExpression: IrFunctionExpression): IrExpression { // Inline the lambda. Lambda parameters will be substituted with lambda arguments. val newExpression = inlineFunction( - expression, - functionArgument.function, + irCall, + irFunctionExpression.function, false ) // Substitute lambda arguments with target function arguments. - return newExpression.transform( - this, - null + return newExpression.transform(this, null) + } + + fun inlineAdaptedFunctionReference(irCall: IrCall, irBlock: IrBlock): IrExpression { + val irFunction = irBlock.statements[0] as IrFunction + irFunction.transformChildrenVoid(this) + val irFunctionReference = irBlock.statements[1] as IrFunctionReference + val inlinedFunctionReference = inlineFunctionReference(irCall, irFunctionReference) + return IrBlockImpl( + irCall.startOffset, irCall.endOffset, + inlinedFunctionReference.type, origin = null, + statements = listOf(irFunction, inlinedFunctionReference) ) } - //-----------------------------------------------------------------// + fun inlineFunctionReference(irCall: IrCall, irFunctionReference: IrFunctionReference): IrExpression { + irFunctionReference.transformChildrenVoid(this) + + val function = irFunctionReference.symbol.owner + val functionParameters = function.explicitParameters + val boundFunctionParameters = irFunctionReference.getArgumentsWithIr() + val unboundFunctionParameters = functionParameters - boundFunctionParameters.map { it.first } + val boundFunctionParametersMap = boundFunctionParameters.associate { it.first to it.second } + + var unboundIndex = 0 + val unboundArgsSet = unboundFunctionParameters.toSet() + val valueParameters = irCall.getArgumentsWithIr().drop(1) // Skip dispatch receiver. + + val superType = irFunctionReference.type as IrSimpleType + val superTypeArgumentsMap = irCall.symbol.owner.parentAsClass.typeParameters.associate { typeParam -> + typeParam.symbol to superType.arguments[typeParam.index].typeOrNull!! + } + + val immediateCall = with(irCall) { + when (function) { + is IrConstructor -> { + val classTypeParametersCount = function.parentAsClass.typeParameters.size + IrConstructorCallImpl.fromSymbolOwner( + startOffset, + endOffset, + function.returnType, + function.symbol, + classTypeParametersCount + ) + } + is IrSimpleFunction -> + IrCallImpl( + startOffset, + endOffset, + function.returnType, + function.symbol, + function.typeParameters.size, + function.valueParameters.size + ) + else -> + kotlin.error("Unknown function kind : ${function.render()}") + } + }.apply { + for (parameter in functionParameters) { + val argument = + if (parameter !in unboundArgsSet) { + val arg = boundFunctionParametersMap[parameter]!! + if (arg is IrGetValueWithoutLocation) + arg.withLocation(irCall.startOffset, irCall.endOffset) + else arg + } else { + if (unboundIndex == valueParameters.size && parameter.defaultValue != null) + copyIrElement.copy(parameter.defaultValue!!.expression) as IrExpression + else if (!parameter.isVararg) { + assert(unboundIndex < valueParameters.size) { + "Attempt to use unbound parameter outside of the callee's value parameters" + } + valueParameters[unboundIndex++].second + } else { + val elements = mutableListOf() + while (unboundIndex < valueParameters.size) { + val (param, value) = valueParameters[unboundIndex++] + val substitutedParamType = param.type.substitute(superTypeArgumentsMap) + if (substitutedParamType == parameter.varargElementType!!) + elements += value + else + elements += IrSpreadElementImpl(irCall.startOffset, irCall.endOffset, value) + } + IrVarargImpl( + irCall.startOffset, irCall.endOffset, + parameter.type, + parameter.varargElementType!!, + elements + ) + } + } + when (parameter) { + function.dispatchReceiverParameter -> + this.dispatchReceiver = argument.implicitCastIfNeededTo(function.dispatchReceiverParameter!!.type) + + function.extensionReceiverParameter -> + this.extensionReceiver = argument.implicitCastIfNeededTo(function.extensionReceiverParameter!!.type) + + else -> + putValueArgument( + parameter.index, + argument.implicitCastIfNeededTo(function.valueParameters[parameter.index].type) + ) + } + } + assert(unboundIndex == valueParameters.size) { "Not all arguments of the callee are used" } + for (index in 0 until irFunctionReference.typeArgumentsCount) + putTypeArgument(index, irFunctionReference.getTypeArgument(index)) + }.implicitCastIfNeededTo(irCall.type) + return this@FunctionInlining.visitExpression(super.visitExpression(immediateCall)) + } override fun visitElement(element: IrElement) = element.accept(this, null) } @@ -369,7 +381,8 @@ class FunctionInlining( && irCall.dispatchReceiver is IrGetValue } - //-------------------------------------------------------------------------// + private fun IrExpression.isAdaptedFunctionReference() = + this is IrBlock && this.origin == IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE private inner class ParameterToArgument( val parameter: IrValueParameter, @@ -379,7 +392,8 @@ class FunctionInlining( val isInlinableLambdaArgument: Boolean get() = parameter.isInlineParameter() && (argumentExpression is IrFunctionReference - || argumentExpression is IrFunctionExpression) + || argumentExpression is IrFunctionExpression + || argumentExpression.isAdaptedFunctionReference()) val isImmutableVariableLoad: Boolean get() = argumentExpression.let { argument -> diff --git a/compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineBound.kt b/compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineBound.kt new file mode 100644 index 00000000000..f381f4f6c99 --- /dev/null +++ b/compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineBound.kt @@ -0,0 +1,17 @@ +// DONT_TARGET_EXACT_BACKEND: WASM +// WASM_MUTE_REASON: BINDING_RECEIVERS + +// FILE: 1.kt +package test + +inline fun foo(x: () -> Unit): String { + x() + return "OK" +} + +inline fun String.id(s: String = this, vararg xs: Int): String = s + +// FILE: 2.kt +import test.* + +fun box(): String = foo("Fail"::id) diff --git a/compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineDefault.kt b/compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineDefault.kt new file mode 100644 index 00000000000..bd8f565ec9a --- /dev/null +++ b/compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineDefault.kt @@ -0,0 +1,19 @@ +// DONT_TARGET_EXACT_BACKEND: WASM +// WASM_MUTE_REASON: STDLIB_TEXT +// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType +// WITH_RUNTIME +// KJS_WITH_FULL_RUNTIME + +// FILE: 1.kt +package test + +inline fun foo(mkString: () -> String): String = + mkString() + +inline fun bar (xs: CharArray = charArrayOf('O','K')) = + String(xs) + +// FILE: 2.kt +import test.* + +fun box(): String = foo(::bar) diff --git a/compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVararg.kt b/compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVararg.kt new file mode 100644 index 00000000000..eb009f99f26 --- /dev/null +++ b/compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVararg.kt @@ -0,0 +1,20 @@ +// DONT_TARGET_EXACT_BACKEND: WASM +// WASM_MUTE_REASON: IGNORED_IN_JS +// !LANGUAGE: +NewInference + +// FILE: 1.kt +package test + +inline fun foo(f: (Int, Int) -> Int): Int = + f(42, 117) + +inline fun bar (vararg xs: Int): Int { + var sum = 0 + for (x in xs) sum += x + return sum +} + +// FILE: 2.kt +import test.* + +fun box(): String = if (foo(::bar) == 159) "OK" else "fail" diff --git a/compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargAndDefault.kt b/compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargAndDefault.kt new file mode 100644 index 00000000000..f3e286ce301 --- /dev/null +++ b/compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargAndDefault.kt @@ -0,0 +1,14 @@ +// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType + +// FILE: 1.kt +package test + +inline fun foo(vararg l: Long, s: String = "OK"): String = + if (l.size == 0) s else "Fail" + +inline fun bar(f: () -> String): String = f() + +// FILE: 2.kt +import test.* + +fun box(): String = bar(::foo) diff --git a/compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargInts.kt b/compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargInts.kt new file mode 100644 index 00000000000..58f41020c96 --- /dev/null +++ b/compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargInts.kt @@ -0,0 +1,18 @@ +// !LANGUAGE: +NewInference +// WITH_RUNTIME +// KJS_WITH_FULL_RUNTIME + +// FILE: 1.kt +package test + +inline fun foo(x: (Int, Int) -> Int): Int = + x(120,3) + +inline fun bar(vararg x: Int): Int = + x.sum() + +// FILE: 2.kt +import test.* + +fun box(): String = + if (foo(::bar) == 123) "OK" else "FAIL" diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java index f080a1b5d6e..72138fbfd89 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -1020,6 +1020,46 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/callableReference/topLevelProperty.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/boxInline/callableReference/adaptedReferences") + @TestDataPath("$PROJECT_ROOT") + public class AdaptedReferences { + @Test + public void testAllFilesPresentInAdaptedReferences() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/callableReference/adaptedReferences"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineBound.kt"); + } + + @Test + @TestMetadata("inlineDefault.kt") + public void testInlineDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineDefault.kt"); + } + + @Test + @TestMetadata("inlineVararg.kt") + public void testInlineVararg() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVararg.kt"); + } + + @Test + @TestMetadata("inlineVarargAndDefault.kt") + public void testInlineVarargAndDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargAndDefault.kt"); + } + + @Test + @TestMetadata("inlineVarargInts.kt") + public void testInlineVarargInts() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargInts.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/boxInline/callableReference/bound") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index b5a34bce5e4..d0f0178aca3 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -1020,6 +1020,46 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/callableReference/topLevelProperty.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/boxInline/callableReference/adaptedReferences") + @TestDataPath("$PROJECT_ROOT") + public class AdaptedReferences { + @Test + public void testAllFilesPresentInAdaptedReferences() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/callableReference/adaptedReferences"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineBound.kt"); + } + + @Test + @TestMetadata("inlineDefault.kt") + public void testInlineDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineDefault.kt"); + } + + @Test + @TestMetadata("inlineVararg.kt") + public void testInlineVararg() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVararg.kt"); + } + + @Test + @TestMetadata("inlineVarargAndDefault.kt") + public void testInlineVarargAndDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargAndDefault.kt"); + } + + @Test + @TestMetadata("inlineVarargInts.kt") + public void testInlineVarargInts() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargInts.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/boxInline/callableReference/bound") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java index b27943edb45..58f7c16bd5b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java @@ -1020,6 +1020,46 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/callableReference/topLevelProperty.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/boxInline/callableReference/adaptedReferences") + @TestDataPath("$PROJECT_ROOT") + public class AdaptedReferences { + @Test + public void testAllFilesPresentInAdaptedReferences() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/callableReference/adaptedReferences"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineBound.kt"); + } + + @Test + @TestMetadata("inlineDefault.kt") + public void testInlineDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineDefault.kt"); + } + + @Test + @TestMetadata("inlineVararg.kt") + public void testInlineVararg() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVararg.kt"); + } + + @Test + @TestMetadata("inlineVarargAndDefault.kt") + public void testInlineVarargAndDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargAndDefault.kt"); + } + + @Test + @TestMetadata("inlineVarargInts.kt") + public void testInlineVarargInts() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargInts.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/boxInline/callableReference/bound") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index 82a9a8ed03d..656b29eb9e4 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -1020,6 +1020,46 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTest("compiler/testData/codegen/boxInline/callableReference/topLevelProperty.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/boxInline/callableReference/adaptedReferences") + @TestDataPath("$PROJECT_ROOT") + public class AdaptedReferences { + @Test + public void testAllFilesPresentInAdaptedReferences() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/callableReference/adaptedReferences"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineBound.kt"); + } + + @Test + @TestMetadata("inlineDefault.kt") + public void testInlineDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineDefault.kt"); + } + + @Test + @TestMetadata("inlineVararg.kt") + public void testInlineVararg() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVararg.kt"); + } + + @Test + @TestMetadata("inlineVarargAndDefault.kt") + public void testInlineVarargAndDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargAndDefault.kt"); + } + + @Test + @TestMetadata("inlineVarargInts.kt") + public void testInlineVarargInts() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargInts.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/boxInline/callableReference/bound") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java index b33d5bef291..d50581746ff 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java @@ -1020,6 +1020,46 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO runTest("compiler/testData/codegen/boxInline/callableReference/topLevelProperty.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/boxInline/callableReference/adaptedReferences") + @TestDataPath("$PROJECT_ROOT") + public class AdaptedReferences { + @Test + public void testAllFilesPresentInAdaptedReferences() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/callableReference/adaptedReferences"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_MULTI_MODULE_IR_AGAINST_OLD, true); + } + + @Test + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineBound.kt"); + } + + @Test + @TestMetadata("inlineDefault.kt") + public void testInlineDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineDefault.kt"); + } + + @Test + @TestMetadata("inlineVararg.kt") + public void testInlineVararg() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVararg.kt"); + } + + @Test + @TestMetadata("inlineVarargAndDefault.kt") + public void testInlineVarargAndDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargAndDefault.kt"); + } + + @Test + @TestMetadata("inlineVarargInts.kt") + public void testInlineVarargInts() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargInts.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/boxInline/callableReference/bound") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java index d97680edabe..cb3218d01f0 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java @@ -1020,6 +1020,46 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst runTest("compiler/testData/codegen/boxInline/callableReference/topLevelProperty.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/boxInline/callableReference/adaptedReferences") + @TestDataPath("$PROJECT_ROOT") + public class AdaptedReferences { + @Test + public void testAllFilesPresentInAdaptedReferences() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/callableReference/adaptedReferences"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_MULTI_MODULE_OLD_AGAINST_IR, true); + } + + @Test + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineBound.kt"); + } + + @Test + @TestMetadata("inlineDefault.kt") + public void testInlineDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineDefault.kt"); + } + + @Test + @TestMetadata("inlineVararg.kt") + public void testInlineVararg() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVararg.kt"); + } + + @Test + @TestMetadata("inlineVarargAndDefault.kt") + public void testInlineVarargAndDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargAndDefault.kt"); + } + + @Test + @TestMetadata("inlineVarargInts.kt") + public void testInlineVarargInts() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargInts.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/boxInline/callableReference/bound") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java index 656a28746bd..7873282c37d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java @@ -770,6 +770,44 @@ public class IrJsCodegenInlineES6TestGenerated extends AbstractIrJsCodegenInline runTest("compiler/testData/codegen/boxInline/callableReference/topLevelProperty.kt"); } + @TestMetadata("compiler/testData/codegen/boxInline/callableReference/adaptedReferences") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class AdaptedReferences extends AbstractIrJsCodegenInlineES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInAdaptedReferences() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/callableReference/adaptedReferences"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineBound.kt"); + } + + @TestMetadata("inlineDefault.kt") + public void testInlineDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineDefault.kt"); + } + + @TestMetadata("inlineVararg.kt") + public void testInlineVararg() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVararg.kt"); + } + + @TestMetadata("inlineVarargAndDefault.kt") + public void testInlineVarargAndDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargAndDefault.kt"); + } + + @TestMetadata("inlineVarargInts.kt") + public void testInlineVarargInts() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargInts.kt"); + } + } + @TestMetadata("compiler/testData/codegen/boxInline/callableReference/bound") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java index ad8ae8af225..c2eb3216cec 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java @@ -770,6 +770,44 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes runTest("compiler/testData/codegen/boxInline/callableReference/topLevelProperty.kt"); } + @TestMetadata("compiler/testData/codegen/boxInline/callableReference/adaptedReferences") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class AdaptedReferences extends AbstractIrJsCodegenInlineTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInAdaptedReferences() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/callableReference/adaptedReferences"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineBound.kt"); + } + + @TestMetadata("inlineDefault.kt") + public void testInlineDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineDefault.kt"); + } + + @TestMetadata("inlineVararg.kt") + public void testInlineVararg() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVararg.kt"); + } + + @TestMetadata("inlineVarargAndDefault.kt") + public void testInlineVarargAndDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargAndDefault.kt"); + } + + @TestMetadata("inlineVarargInts.kt") + public void testInlineVarargInts() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargInts.kt"); + } + } + @TestMetadata("compiler/testData/codegen/boxInline/callableReference/bound") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java index 52adc97aede..16d7521b1f4 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java @@ -770,6 +770,44 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { runTest("compiler/testData/codegen/boxInline/callableReference/topLevelProperty.kt"); } + @TestMetadata("compiler/testData/codegen/boxInline/callableReference/adaptedReferences") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class AdaptedReferences extends AbstractJsCodegenInlineTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInAdaptedReferences() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/callableReference/adaptedReferences"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineBound.kt"); + } + + @TestMetadata("inlineDefault.kt") + public void testInlineDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineDefault.kt"); + } + + @TestMetadata("inlineVararg.kt") + public void testInlineVararg() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVararg.kt"); + } + + @TestMetadata("inlineVarargAndDefault.kt") + public void testInlineVarargAndDefault() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargAndDefault.kt"); + } + + @TestMetadata("inlineVarargInts.kt") + public void testInlineVarargInts() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/adaptedReferences/inlineVarargInts.kt"); + } + } + @TestMetadata("compiler/testData/codegen/boxInline/callableReference/bound") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)