From a38040680c584715092ced10dba8639607e7ec85 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Fri, 25 Nov 2022 18:19:10 +0100 Subject: [PATCH] K2: Do not use KFunctionN as representation type for adapted references Beside some corner cases, it's already prohibited in K1 because adaptation have a bit strange nature (they don't represent any existing real function exactly) ^KT-55137 Fixed --- ...sisCompilerTestFE10TestdataTestGenerated.java | 6 ++++++ .../FirOldFrontendDiagnosticsTestGenerated.java | 6 ++++++ ...endDiagnosticsWithLightTreeTestGenerated.java | 6 ++++++ .../fir/backend/generators/AdapterGenerator.kt | 6 +----- .../generators/CallAndReferenceGenerator.kt | 3 ++- .../codegen/FirBlackBoxCodegenTestGenerated.java | 6 ++++++ .../resolve/calls/CallableReferenceResolution.kt | 12 +++++++++++- .../fir/callableReferenceConversionTopLevel.kt | 9 +++++++++ .../adapted/noKFunctionForAdaptation.fir.kt | 16 ++++++++++++++++ .../adapted/noKFunctionForAdaptation.kt | 16 ++++++++++++++++ .../adaptedReferenceAgainstReflectionType.fir.kt | 2 +- ...arningOnReferenceAgainstReflectiveType.fir.kt | 2 +- .../caoWithAdaptationForSam.fir.ir.txt | 12 ++++++------ .../caoWithAdaptationForSam.fir.kt.txt | 4 ++-- .../test/runners/DiagnosticTestGenerated.java | 6 ++++++ .../codegen/IrBlackBoxCodegenTestGenerated.java | 6 ++++++ .../p-3/pos/1.4.fir.kt | 2 +- 17 files changed, 102 insertions(+), 18 deletions(-) create mode 100644 compiler/testData/codegen/box/fir/callableReferenceConversionTopLevel.kt create mode 100644 compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.fir.kt create mode 100644 compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.kt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 04e2f7b4f1b..4b552610d25 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -3111,6 +3111,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/callableReference/adapted"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @Test + @TestMetadata("noKFunctionForAdaptation.kt") + public void testNoKFunctionForAdaptation() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.kt"); + } + @Test @TestMetadata("simpleAdaptationOutsideOfCall.kt") public void testSimpleAdaptationOutsideOfCall() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 3ad81affa5e..c5164b4bce0 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -3117,6 +3117,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/callableReference/adapted"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @Test + @TestMetadata("noKFunctionForAdaptation.kt") + public void testNoKFunctionForAdaptation() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.kt"); + } + @Test @TestMetadata("simpleAdaptationOutsideOfCall.kt") public void testSimpleAdaptationOutsideOfCall() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index eeb41cc45a7..c6eb59bd4e5 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -3111,6 +3111,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/callableReference/adapted"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @Test + @TestMetadata("noKFunctionForAdaptation.kt") + public void testNoKFunctionForAdaptation() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.kt"); + } + @Test @TestMetadata("simpleAdaptationOutsideOfCall.kt") public void testSimpleAdaptationOutsideOfCall() throws Exception { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt index 5dd631d988a..71bd09b6764 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt @@ -98,8 +98,7 @@ internal class AdapterGenerator( * At the use site, instead of referenced, we can put the suspend lambda as an adapter. */ private fun needSuspendConversion(type: IrSimpleType, function: IrFunction): Boolean = - // TODO: should refer to LanguageVersionSettings.SuspendConversion - type.isKSuspendFunction() && !function.isSuspend + type.isSuspendFunction() && !function.isSuspend /** * For example, @@ -133,9 +132,6 @@ internal class AdapterGenerator( } } - internal fun ConeKotlinType.kFunctionTypeToFunctionType(): IrSimpleType = - reflectFunctionTypeToNonReflectFunctionType(session).toIrType() as IrSimpleType - internal fun generateAdaptedCallableReference( callableReferenceAccess: FirCallableReferenceAccess, explicitReceiverExpression: IrExpression?, diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt index bd940c9f997..8687eafe67c 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt @@ -156,7 +156,8 @@ class CallAndReferenceGenerator( if (adapterGenerator.needToGenerateAdaptedCallableReference(callableReferenceAccess, type, function)) { // Receivers are being applied inside with(adapterGenerator) { - val adaptedType = callableReferenceAccess.typeRef.coneType.kFunctionTypeToFunctionType() + // TODO: Figure out why `adaptedType` is different from the `type`? + val adaptedType = callableReferenceAccess.typeRef.coneType.toIrType() as IrSimpleType generateAdaptedCallableReference(callableReferenceAccess, explicitReceiverExpression, symbol, adaptedType) } } else { 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 f0315e755ec..58387997112 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 @@ -18319,6 +18319,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/fir/assertEqualsFakeOverride.kt"); } + @Test + @TestMetadata("callableReferenceConversionTopLevel.kt") + public void testCallableReferenceConversionTopLevel() throws Exception { + runTest("compiler/testData/codegen/box/fir/callableReferenceConversionTopLevel.kt"); + } + @Test @TestMetadata("callableReferenceToJavaField.kt") public void testCallableReferenceToJavaField() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt index 5629bb8eb60..fa2c3a787dd 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt @@ -136,7 +136,7 @@ private fun buildReflectionType( ?: FunctionTypeKind.Function return createFunctionType( - baseFunctionTypeKind.reflectKind(), + if (callableReferenceAdaptation == null) baseFunctionTypeKind.reflectKind() else baseFunctionTypeKind.nonReflectKind(), parameters, receiverType = receiverType.takeIf { fir.receiverParameter != null }, rawReturnType = returnType, @@ -239,9 +239,11 @@ private fun BodyResolveComponents.getCallableReferenceAdaptation( mappedArguments[valueParameter] = ResolvedCallArgument.VarargArgument(varargElements) } + var isThereVararg = mappedVarargElements.isNotEmpty() for (valueParameter in function.valueParameters) { if (valueParameter.isVararg && valueParameter !in mappedArguments) { mappedArguments[valueParameter] = ResolvedCallArgument.VarargArgument(emptyList()) + isThereVararg = true } } @@ -264,6 +266,14 @@ private fun BodyResolveComponents.getCallableReferenceAdaptation( CallableReferenceConversionStrategy.NoConversion } + if (defaults == 0 && !isThereVararg && + coercionStrategy == CoercionStrategy.NO_COERCION && conversionStrategy == CallableReferenceConversionStrategy.NoConversion + ) { + // Do not create adaptation for trivial (id) conversion as it makes resulting type FunctionN instead of KFunctionN + // It happens because adapted references do not support reflection (see KT-40406) + return null + } + @Suppress("UNCHECKED_CAST") return CallableReferenceAdaptation( mappedArgumentTypes as Array, diff --git a/compiler/testData/codegen/box/fir/callableReferenceConversionTopLevel.kt b/compiler/testData/codegen/box/fir/callableReferenceConversionTopLevel.kt new file mode 100644 index 00000000000..ef8ad8b9f8e --- /dev/null +++ b/compiler/testData/codegen/box/fir/callableReferenceConversionTopLevel.kt @@ -0,0 +1,9 @@ +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_K1: JVM_IR + +fun foo(x: String = "OK"): String = x + +fun box(): String { + val f: () -> String = ::foo + return f() +} diff --git a/compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.fir.kt b/compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.fir.kt new file mode 100644 index 00000000000..33e6272e914 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.fir.kt @@ -0,0 +1,16 @@ +// SKIP_TXT +fun foo(x: String = "O"): String = x +fun bar(x: String = "K"): String = x + +fun dump(dumpStrategy: String) { + val k0: kotlin.reflect.KFunction0 = returnAdapter(::foo) // Error: ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE + val k1: kotlin.reflect.KFunction0 = ::foo + // Should be error here, too + val k2: kotlin.reflect.KFunction0 = if (dumpStrategy == "KotlinLike") ::foo else ::bar + + val f0: Function0 = returnAdapter(::foo) + val f1: Function0 = ::foo + val f2: Function0 = if (dumpStrategy == "KotlinLike") ::foo else ::bar +} + +fun returnAdapter(a: kotlin.reflect.KFunction0) = a diff --git a/compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.kt b/compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.kt new file mode 100644 index 00000000000..39bd6ac3a7f --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.kt @@ -0,0 +1,16 @@ +// SKIP_TXT +fun foo(x: String = "O"): String = x +fun bar(x: String = "K"): String = x + +fun dump(dumpStrategy: String) { + val k0: kotlin.reflect.KFunction0 = returnAdapter(::foo) // Error: ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE + val k1: kotlin.reflect.KFunction0 = ::foo + // Should be error here, too + val k2: kotlin.reflect.KFunction0 = if (dumpStrategy == "KotlinLike") ::foo else ::bar + + val f0: Function0 = returnAdapter(::foo) + val f1: Function0 = ::foo + val f2: Function0 = if (dumpStrategy == "KotlinLike") ::foo else ::bar +} + +fun returnAdapter(a: kotlin.reflect.KFunction0) = a diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.fir.kt index e87f1e5ae32..e042c41bd70 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.fir.kt @@ -22,6 +22,6 @@ object Local { fun baz(x: Int, y: Int = 0): Int = 0 fun test() { - bar(::baz) + bar(::baz) } } diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.fir.kt index 1bc8fa8653e..f24ac33174d 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.fir.kt @@ -22,6 +22,6 @@ object Local { fun baz(x: Int, y: Int = 0): Int = 0 fun test() { - bar(::baz) + bar(::baz) } } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt index 456baed1a12..a30761d3011 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt @@ -107,7 +107,7 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt BLOCK type=kotlin.Unit origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.A [val] GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A - VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.reflect.KFunction1 [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Function1 [val] FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int @@ -118,19 +118,19 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null $receiver: GET_VAR 'val tmp_0: .A [val] declared in .test1' type=.A origin=null i: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo - GET_VAR 'val tmp_1: kotlin.reflect.KFunction1 [val] declared in .test1' type=kotlin.reflect.KFunction1 origin=null + GET_VAR 'val tmp_1: kotlin.Function1 [val] declared in .test1' type=kotlin.Function1 origin=null newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null $receiver: GET_VAR 'val tmp_0: .A [val] declared in .test1' type=.A origin=null i: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo - GET_VAR 'val tmp_1: kotlin.reflect.KFunction1 [val] declared in .test1' type=kotlin.reflect.KFunction1 origin=null + GET_VAR 'val tmp_1: kotlin.Function1 [val] declared in .test1' type=kotlin.Function1 origin=null other: CONST Int type=kotlin.Int value=1 FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY BLOCK type=kotlin.Unit origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:.B [val] GET_OBJECT 'CLASS OBJECT name:B modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.B - VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.reflect.KFunction1 [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Function1 [val] FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int @@ -141,12 +141,12 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt CALL 'public final fun set (i: .IFoo2, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null $receiver: GET_VAR 'val tmp_2: .B [val] declared in .test2' type=.B origin=null i: TYPE_OP type=.IFoo2 origin=SAM_CONVERSION typeOperand=.IFoo2 - GET_VAR 'val tmp_3: kotlin.reflect.KFunction1 [val] declared in .test2' type=kotlin.reflect.KFunction1 origin=null + GET_VAR 'val tmp_3: kotlin.Function1 [val] declared in .test2' type=kotlin.Function1 origin=null newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null $receiver: GET_VAR 'val tmp_2: .B [val] declared in .test2' type=.B origin=null i: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo - GET_VAR 'val tmp_3: kotlin.reflect.KFunction1 [val] declared in .test2' type=kotlin.reflect.KFunction1 origin=null + GET_VAR 'val tmp_3: kotlin.Function1 [val] declared in .test2' type=kotlin.Function1 origin=null other: CONST Int type=kotlin.Int value=1 FUN name:test3 visibility:public modality:FINAL <> (fn:kotlin.Function1) returnType:kotlin.Unit VALUE_PARAMETER name:fn index:0 type:kotlin.Function1 diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt index 5a02607a8f2..2caa5b1e5f7 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt @@ -46,7 +46,7 @@ fun withVararg(vararg xs: Int): Int { fun test1() { { // BLOCK val : A = A - val : KFunction1 = local fun withVararg(p0: Int) { + val : Function1 = local fun withVararg(p0: Int) { withVararg(xs = [p0]) } @@ -57,7 +57,7 @@ fun test1() { fun test2() { { // BLOCK val : B = B - val : KFunction1 = local fun withVararg(p0: Int) { + val : Function1 = local fun withVararg(p0: Int) { withVararg(xs = [p0]) } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index cac555b8b19..830658ef427 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -3117,6 +3117,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/callableReference/adapted"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @Test + @TestMetadata("noKFunctionForAdaptation.kt") + public void testNoKFunctionForAdaptation() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.kt"); + } + @Test @TestMetadata("simpleAdaptationOutsideOfCall.kt") public void testSimpleAdaptationOutsideOfCall() throws Exception { 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 fddd3139813..a2f3516ac18 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 @@ -18319,6 +18319,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/fir/assertEqualsFakeOverride.kt"); } + @Test + @TestMetadata("callableReferenceConversionTopLevel.kt") + public void testCallableReferenceConversionTopLevel() throws Exception { + runTest("compiler/testData/codegen/box/fir/callableReferenceConversionTopLevel.kt"); + } + @Test @TestMetadata("callableReferenceToJavaField.kt") public void testCallableReferenceToJavaField() throws Exception { diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/bidirectional-resolution-for-callable-calls/p-3/pos/1.4.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/bidirectional-resolution-for-callable-calls/p-3/pos/1.4.fir.kt index 94a2dae9984..858ae5cb8c2 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/bidirectional-resolution-for-callable-calls/p-3/pos/1.4.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/bidirectional-resolution-for-callable-calls/p-3/pos/1.4.fir.kt @@ -27,7 +27,7 @@ class Case2() { } fun case() { - foo(")!>::invoke, ")!>::invoke) + foo(")!>::invoke, ")!>::invoke) foo(::invoke, ::invoke) foo(::invoke, ::invoke) foo(::invoke, ::invoke)