diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java index aa97d06e1c7..aaa3895409c 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java @@ -2599,6 +2599,16 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); } + @TestMetadata("adaptedReferenceAgainstKCallable.kt") + public void testAdaptedReferenceAgainstKCallable() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstKCallable.kt"); + } + + @TestMetadata("adaptedReferenceAgainstReflectionType.kt") + public void testAdaptedReferenceAgainstReflectionType() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.kt"); + } + public void testAllFilesPresentInResolve() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/callableReference/resolve"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @@ -2663,6 +2673,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte runTest("compiler/testData/diagnostics/tests/callableReference/resolve/commonSupertypeFromReturnTypesOfCallableReference.kt"); } + @TestMetadata("compatibilityWarningOnReferenceAgainstReflectiveType.kt") + public void testCompatibilityWarningOnReferenceAgainstReflectiveType() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.kt"); + } + @TestMetadata("constructor.kt") public void testConstructor() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/resolve/constructor.kt"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 99fe86c562c..5d64b5fd14a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -810,6 +810,8 @@ public interface Errors { DiagnosticFactory0 CALLABLE_REFERENCE_TO_JAVA_SYNTHETIC_PROPERTY = DiagnosticFactory0.create(WARNING); + DiagnosticFactory0 ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE = DiagnosticFactory0.create(ERROR); + // Destructuring-declarations DiagnosticFactory0 INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION = DiagnosticFactory0.create(ERROR, DEFAULT); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index ed4409c196f..f493c66fa7d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -990,6 +990,8 @@ public class DefaultErrorMessages { MAP.put(CALLABLE_REFERENCE_TO_JAVA_SYNTHETIC_PROPERTY, "References to the synthetic extension properties for a Java get/set methods aren't supported fully, please use reference to a method"); + MAP.put(ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE, "Adapted callable reference cannot be resolved against reflective types"); + //Inline MAP.put(NON_PUBLIC_CALL_FROM_PUBLIC_INLINE, "Public-API inline function cannot access non-public-API ''{0}''", SHORT_NAMES_IN_TYPES, SHORT_NAMES_IN_TYPES); MAP.put(PRIVATE_CLASS_MEMBER_FROM_INLINE, "Non-private inline function cannot access members of private classes: ''{0}''", SHORT_NAMES_IN_TYPES, SHORT_NAMES_IN_TYPES); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt index bd2e264ba2d..7d19c1ea5af 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt @@ -236,6 +236,14 @@ class DiagnosticReporterByTrackingStrategy( ) ) } + + AdaptedCallableReferenceIsUsedWithReflection::class.java -> { + trace.report( + ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE.on( + callArgument.psiCallArgument.valueArgument.asElement() + ) + ) + } } } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolution.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolution.kt index 56a1d5a0118..5dbdd80aedb 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolution.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolution.kt @@ -228,6 +228,12 @@ class CallableReferencesCandidateFactory( markCandidateForCompatibilityResolve(diagnostics) } + if (callableReferenceAdaptation != null && expectedType != null && hasNonTrivialAdaptation(callableReferenceAdaptation)) { + if (!expectedType.isFunctionType && !expectedType.isSuspendFunctionType) { // expectedType has some reflection type + diagnostics.add(AdaptedCallableReferenceIsUsedWithReflection(argument)) + } + } + if (callableReferenceAdaptation != null && callableReferenceAdaptation.defaults != 0 && !callComponents.languageVersionSettings.supportsFeature(LanguageFeature.FunctionReferenceWithDefaultValueAsOtherType) @@ -278,11 +284,14 @@ class CallableReferencesCandidateFactory( if (callableReferenceAdaptation == null) return false - return callableReferenceAdaptation.defaults != 0 || + return hasNonTrivialAdaptation(callableReferenceAdaptation) + } + + private fun hasNonTrivialAdaptation(callableReferenceAdaptation: CallableReferenceAdaptation) = + callableReferenceAdaptation.defaults != 0 || callableReferenceAdaptation.suspendConversionStrategy != SuspendConversionStrategy.NO_CONVERSION || callableReferenceAdaptation.coercionStrategy != CoercionStrategy.NO_COERCION || callableReferenceAdaptation.mappedArguments.values.any { it is ResolvedCallArgument.VarargArgument } - } private enum class VarargMappingState { UNMAPPED, MAPPED_WITH_PLAIN_ARGS, MAPPED_WITH_ARRAY @@ -296,6 +305,11 @@ class CallableReferencesCandidateFactory( ): CallableReferenceAdaptation? { if (callComponents.languageVersionSettings.apiVersion < ApiVersion.KOTLIN_1_4) return null + if (expectedType == null) return null + + // Do not adapt references against KCallable type as it's impossible to map defaults/vararg to absent parameters of KCallable + if (ReflectionTypes.hasKCallableTypeFqName(expectedType)) return null + val inputOutputTypes = extractInputOutputTypesFromCallableReferenceExpectedType(expectedType) ?: return null val expectedArgumentCount = inputOutputTypes.inputTypes.size - unboundReceiverCount diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCallDiagnostics.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCallDiagnostics.kt index c737133a9ad..55aa84d1835 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCallDiagnostics.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCallDiagnostics.kt @@ -263,4 +263,13 @@ class CompatibilityWarningOnArgument( override fun report(reporter: DiagnosticReporter) { reporter.onCallArgument(argument, this) } +} + +class AdaptedCallableReferenceIsUsedWithReflection( + val argument: CallableReferenceKotlinCallArgument, +) : KotlinCallDiagnostic(RESOLVED_WITH_ERROR) { + override fun report(reporter: DiagnosticReporter) { + reporter.onCallArgument(argument, this) + } + } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstKCallable.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstKCallable.kt new file mode 100644 index 00000000000..f710e778884 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstKCallable.kt @@ -0,0 +1,13 @@ +// FIR_IDENTICAL +// !LANGUAGE: -AdaptedCallableReferenceAgainstReflectiveType +// !DIAGNOSTICS: -UNUSED_PARAMETER + +import kotlin.reflect.KCallable + +fun take(k: KCallable<*>) {} + +fun foo(x: Int = 0) {} + +fun test() { + take(::foo) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstKCallable.txt b/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstKCallable.txt new file mode 100644 index 00000000000..19751fde6fb --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstKCallable.txt @@ -0,0 +1,5 @@ +package + +public fun foo(/*0*/ x: kotlin.Int = ...): kotlin.Unit +public fun take(/*0*/ k: kotlin.reflect.KCallable<*>): kotlin.Unit +public fun test(): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.fir.kt new file mode 100644 index 00000000000..e87f1e5ae32 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.fir.kt @@ -0,0 +1,27 @@ +// !LANGUAGE: -AdaptedCallableReferenceAgainstReflectiveType +DisableCompatibilityModeForNewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER + +import kotlin.reflect.KFunction1 + +fun foo(x: Int): Unit {} // (1) +fun bar(f: KFunction1) {} + +fun test() { + bar(::foo) // OK, foo resolved to (1) +} + +object Scope { + fun foo(x: Int, y: Int = 0): Int = 0 // (2) + + fun test() { + bar(::foo) // Error and foo should be resolved to (2) + } +} + +object Local { + fun baz(x: Int, y: Int = 0): Int = 0 + + fun test() { + bar(::baz) + } +} diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.kt new file mode 100644 index 00000000000..b73b0e06088 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.kt @@ -0,0 +1,27 @@ +// !LANGUAGE: -AdaptedCallableReferenceAgainstReflectiveType +DisableCompatibilityModeForNewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER + +import kotlin.reflect.KFunction1 + +fun foo(x: Int): Unit {} // (1) +fun bar(f: KFunction1) {} + +fun test() { + bar(::foo) // OK, foo resolved to (1) +} + +object Scope { + fun foo(x: Int, y: Int = 0): Int = 0 // (2) + + fun test() { + bar(::foo) // Error and foo should be resolved to (2) + } +} + +object Local { + fun baz(x: Int, y: Int = 0): Int = 0 + + fun test() { + bar(::baz) + } +} diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.txt b/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.txt new file mode 100644 index 00000000000..d92330a3167 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.txt @@ -0,0 +1,23 @@ +package + +public fun bar(/*0*/ f: kotlin.reflect.KFunction1): kotlin.Unit +public fun foo(/*0*/ x: kotlin.Int): kotlin.Unit +public fun test(): kotlin.Unit + +public object Local { + private constructor Local() + public final fun baz(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int = ...): kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object Scope { + private constructor Scope() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int = ...): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.fir.kt new file mode 100644 index 00000000000..1bc8fa8653e --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.fir.kt @@ -0,0 +1,27 @@ +// !LANGUAGE: -AdaptedCallableReferenceAgainstReflectiveType -DisableCompatibilityModeForNewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER + +import kotlin.reflect.KFunction1 + +fun foo(x: Int): Unit {} // (1) +fun bar(f: KFunction1) {} + +fun test() { + bar(::foo) +} + +object Scope { + fun foo(x: Int, y: Int = 0): Int = 0 // (2) + + fun test() { + bar(::foo) + } +} + +object Local { + fun baz(x: Int, y: Int = 0): Int = 0 + + fun test() { + bar(::baz) + } +} diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.kt new file mode 100644 index 00000000000..f094fa32a12 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.kt @@ -0,0 +1,27 @@ +// !LANGUAGE: -AdaptedCallableReferenceAgainstReflectiveType -DisableCompatibilityModeForNewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER + +import kotlin.reflect.KFunction1 + +fun foo(x: Int): Unit {} // (1) +fun bar(f: KFunction1) {} + +fun test() { + bar(::foo) +} + +object Scope { + fun foo(x: Int, y: Int = 0): Int = 0 // (2) + + fun test() { + bar(::foo) + } +} + +object Local { + fun baz(x: Int, y: Int = 0): Int = 0 + + fun test() { + bar(::baz) + } +} diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.txt b/compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.txt new file mode 100644 index 00000000000..d92330a3167 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.txt @@ -0,0 +1,23 @@ +package + +public fun bar(/*0*/ f: kotlin.reflect.KFunction1): kotlin.Unit +public fun foo(/*0*/ x: kotlin.Int): kotlin.Unit +public fun test(): kotlin.Unit + +public object Local { + private constructor Local() + public final fun baz(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int = ...): kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object Scope { + private constructor Scope() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int = ...): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/ir/irText/expressions/callableReferences/funWithDefaultParametersAsKCallableStar.txt b/compiler/testData/ir/irText/expressions/callableReferences/funWithDefaultParametersAsKCallableStar.txt index e77faa1b419..025a50c0133 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/funWithDefaultParametersAsKCallableStar.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/funWithDefaultParametersAsKCallableStar.txt @@ -58,7 +58,7 @@ FILE fqName: fileName:/funWithDefaultParametersAsKCallableStar.kt FUN name:testDefaultsOnlyStar visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun useKCallableStar (fn: kotlin.reflect.KCallable<*>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUNCTION_REFERENCE 'public final fun defaultsOnly (x: kotlin.String): kotlin.Int declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + fn: FUNCTION_REFERENCE 'public final fun defaultsOnly (x: kotlin.String): kotlin.Int declared in ' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= FUN name:testRegularAndDefaultsStar visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun useKCallableStar (fn: kotlin.reflect.KCallable<*>): kotlin.Unit declared in ' type=kotlin.Unit origin=null @@ -66,8 +66,8 @@ FILE fqName: fileName:/funWithDefaultParametersAsKCallableStar.kt FUN name:testVarargsStar visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun useKCallableStar (fn: kotlin.reflect.KCallable<*>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUNCTION_REFERENCE 'public final fun varargs (vararg xs: kotlin.String): kotlin.Int declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + fn: FUNCTION_REFERENCE 'public final fun varargs (vararg xs: kotlin.String): kotlin.Int declared in ' type=kotlin.reflect.KFunction1, kotlin.Int> origin=null reflectionTarget= FUN name:testCtorStar visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun useKCallableStar (fn: kotlin.reflect.KCallable<*>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUNCTION_REFERENCE 'public constructor (x: kotlin.String) [primary] declared in .C' type=kotlin.reflect.KFunction0<.C> origin=null reflectionTarget= + fn: FUNCTION_REFERENCE 'public constructor (x: kotlin.String) [primary] declared in .C' type=kotlin.reflect.KFunction1.C> origin=null reflectionTarget= diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 016bc9898bc..d9314b1d77c 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -2606,6 +2606,16 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); } + @TestMetadata("adaptedReferenceAgainstKCallable.kt") + public void testAdaptedReferenceAgainstKCallable() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstKCallable.kt"); + } + + @TestMetadata("adaptedReferenceAgainstReflectionType.kt") + public void testAdaptedReferenceAgainstReflectionType() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.kt"); + } + public void testAllFilesPresentInResolve() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/callableReference/resolve"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @@ -2670,6 +2680,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali runTest("compiler/testData/diagnostics/tests/callableReference/resolve/commonSupertypeFromReturnTypesOfCallableReference.kt"); } + @TestMetadata("compatibilityWarningOnReferenceAgainstReflectiveType.kt") + public void testCompatibilityWarningOnReferenceAgainstReflectiveType() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.kt"); + } + @TestMetadata("constructor.kt") public void testConstructor() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/resolve/constructor.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 668625ff53e..2f49bfb4cbe 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -2601,6 +2601,16 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); } + @TestMetadata("adaptedReferenceAgainstKCallable.kt") + public void testAdaptedReferenceAgainstKCallable() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstKCallable.kt"); + } + + @TestMetadata("adaptedReferenceAgainstReflectionType.kt") + public void testAdaptedReferenceAgainstReflectionType() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.kt"); + } + public void testAllFilesPresentInResolve() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/callableReference/resolve"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @@ -2665,6 +2675,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/callableReference/resolve/commonSupertypeFromReturnTypesOfCallableReference.kt"); } + @TestMetadata("compatibilityWarningOnReferenceAgainstReflectiveType.kt") + public void testCompatibilityWarningOnReferenceAgainstReflectiveType() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.kt"); + } + @TestMetadata("constructor.kt") public void testConstructor() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/resolve/constructor.kt"); diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index 4f2a80e946e..ff530cf4f5e 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -133,6 +133,7 @@ enum class LanguageFeature( CorrectSourceMappingSyntax(KOTLIN_1_5, kind = UNSTABLE_FEATURE), ProperArrayConventionSetterWithDefaultCalls(KOTLIN_1_5, kind = OTHER), DisableCompatibilityModeForNewInference(KOTLIN_1_5, defaultState = LanguageFeature.State.DISABLED), + AdaptedCallableReferenceAgainstReflectiveType(KOTLIN_1_5, defaultState = LanguageFeature.State.DISABLED), // Temporarily disabled, see KT-27084/KT-22379 SoundSmartcastFromLoopConditionForLoopAssignedVariables(sinceVersion = null, kind = BUG_FIX),