From 2f3293f99ed3ffcb9fbed94fabd0b02556e9fa14 Mon Sep 17 00:00:00 2001 From: Kirill Rakhman Date: Tue, 18 Jul 2023 10:16:26 +0200 Subject: [PATCH] [FIR] Skip redundant INAPPLICABLE_CANDIDATE on call with unresolved callable reference argument A new resolution diagnostic UnsuccessfulCallableReferenceAtom is introduced that is used in EagerResolveOfCallableReferences. No diagnostic is reported on unresolved calls with this diagnostic because #KT-59856 --- .../callableReferences/companions.kt | 4 +-- ...llableReferencesAfterAllSimpleArguments.kt | 4 +-- .../callableReferences/implicitTypes.kt | 2 +- .../implicitTypes.reversed.kt | 2 +- .../coneDiagnosticToFirDiagnostic.kt | 3 ++ .../fir/resolve/calls/ResolutionStages.kt | 10 ++++-- .../fir/resolve/calls/ResolutionDiagnostic.kt | 2 ++ .../annotationRenderingInTypes.fir.kt | 2 +- .../adapted/noKFunctionForAdaptation.fir.kt | 4 +-- ...nstraintFromLHSWithCorrectDirection.fir.kt | 2 +- ...intFromLHSWithCorrectDirectionError.fir.kt | 2 +- ...expectedTypeAsSubtypeOfFunctionType.fir.kt | 2 +- .../noAmbiguityMemberVsTopLevel.fir.kt | 4 +-- .../function/unresolved.fir.kt | 4 +-- .../generic/dependOnArgumentType.fir.kt | 4 +-- .../generic/explicitTypeArguments.fir.kt | 2 +- .../generic/genericExtensionFunction.fir.kt | 4 +-- .../resolutionWithGenericCallable.fir.kt | 2 +- ...nericCallWithReferenceAgainstVararg.fir.kt | 2 +- .../property/kt7945_unrelatedClass.fir.kt | 10 ------ .../property/kt7945_unrelatedClass.kt | 1 + ...aptedReferenceAgainstReflectionType.fir.kt | 2 +- .../resolve/byGenericArgType.fir.kt | 2 +- ...ingOnReferenceAgainstReflectiveType.fir.kt | 2 +- .../resolve/kt35887_simple.fir.kt | 2 +- ...leReferencesAfterAllSimpleArguments.fir.kt | 4 +-- .../resolve/withGenericFun.fir.kt | 2 +- .../callableReferenceToLocalVariable.fir.kt | 2 +- .../unsupported/localVariable.fir.kt | 2 +- .../localVariableWithSubstitution.fir.kt | 2 +- .../parameterWithSubstitution.fir.kt | 2 +- .../tests/delegation/kt49477.fir.kt | 2 +- .../tests/delegation/kt49477Error.fir.kt | 2 +- .../tests/inference/kt39220.fir.kt | 32 +++++++++---------- .../inference/regressions/kt32862_none.fir.kt | 2 +- .../inference/regressions/kt34282.fir.kt | 2 +- ...boutUnresolvedReferenceAsUnresolved.fir.kt | 7 ---- ...ortAboutUnresolvedReferenceAsUnresolved.kt | 1 + .../specialCallsWithCallableReferences.fir.kt | 6 ++-- ...nceToSamFunctionAgainstExpectedType.fir.kt | 2 +- .../tests/regressions/ea72837.fir.kt | 4 +-- ...spendConversionForCallableReference.fir.kt | 2 +- .../tests/varargs/varargViewedAsArray.fir.kt | 10 +++--- .../callableReferenceOnUnresolvedLHS.fir.kt | 4 +-- ...pendConversionForCallableReferences.fir.kt | 4 +-- ...callableReferenceToASuspendFunction.fir.kt | 4 +-- .../callableReferenceOnParameter.fir.kt | 2 +- .../inference/delegates/kt50994.fir.kt | 2 +- .../p-3/neg/1.1.fir.kt | 4 +-- 49 files changed, 91 insertions(+), 95 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.fir.kt diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.kt index 61165ab4e70..4018e5020bd 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.kt @@ -34,13 +34,13 @@ fun main() { foo3(KotlinClass::baz) // Type mismatch - foo1(KotlinClass::bar) + foo1(KotlinClass::bar) foo2(KotlinClass::bar) foo3(KotlinClass::bar) foo1(KotlinClass2::bar) // Type mismatch - foo2(KotlinClass2::bar) + foo2(KotlinClass2::bar) foo3(KotlinClass2::bar) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/resolveCallableReferencesAfterAllSimpleArguments.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/resolveCallableReferencesAfterAllSimpleArguments.kt index 1cc17a775ec..4532c22b733 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/resolveCallableReferencesAfterAllSimpleArguments.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/resolveCallableReferencesAfterAllSimpleArguments.kt @@ -7,6 +7,6 @@ fun bar(f: (T) -> Unit, e: T) {} fun baz(e: T, f: (T) -> Unit) {} fun test(a: A, b: B) { - baz(a, ::fooB) - bar(::fooB, a) + baz(a, ::fooB) + bar(::fooB, a) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.kt index 6298db84ebc..1c76deeea5d 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.kt @@ -3,5 +3,5 @@ fun use(x: (T) -> R): (T) -> R = x fun foo() = use(::bar) fun bar(x: String) = 1 -fun loop1() = use(::loop2) +fun loop1() = use(::loop2) fun loop2() = loop1() diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.reversed.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.reversed.kt index 590d4b2f871..561f29d2471 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.reversed.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.reversed.kt @@ -3,5 +3,5 @@ fun use(x: (T) -> R): (T) -> R = x fun foo() = use(::bar) fun bar(x: String) = 1 -fun loop1() = use(::loop2) +fun loop1() = use(::loop2) fun loop2() = loop1() diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt index 017387ee586..491945a02d5 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt @@ -255,6 +255,9 @@ private fun mapInapplicableCandidateError( // And the errors should be reported there is ErrorTypeInArguments -> null + // see EagerResolveOfCallableReferences + is UnsuccessfulCallableReferenceAtom -> null + is MultipleContextReceiversApplicableForExtensionReceivers -> FirErrors.AMBIGUOUS_CALL_WITH_IMPLICIT_CONTEXT_RECEIVER.createOn(qualifiedAccessSource ?: source) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt index 7e39cd4c847..695165a7eb4 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.fir.resolve.calls -import org.jetbrains.kotlin.KtFakeSourceElementKind import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.FirElement @@ -42,6 +41,7 @@ import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability import org.jetbrains.kotlin.resolve.deprecation.DeprecationLevelValue import org.jetbrains.kotlin.resolve.descriptorUtil.DYNAMIC_EXTENSION_FQ_NAME import org.jetbrains.kotlin.types.AbstractNullabilityChecker +import org.jetbrains.kotlin.types.AbstractTypeChecker import org.jetbrains.kotlin.types.TypeApproximatorConfiguration import org.jetbrains.kotlin.util.OperatorNameConventions @@ -514,7 +514,13 @@ internal object EagerResolveOfCallableReferences : CheckerStage() { val (applicability, success) = context.bodyResolveComponents.callResolver.resolveCallableReference(candidate.csBuilder, atom) if (!success) { - sink.yieldDiagnostic(InapplicableCandidate) + // If the resolution was unsuccessful, we ensure that an error will be reported for the callable reference + // during completion by using the `resultingReference` of the postponed atom. + // We assert that the `resultingReference` is set to an error reference and the atom is in fact postponed. + check(atom.resultingReference is FirErrorReferenceWithCandidate) + if (AbstractTypeChecker.RUN_SLOW_ASSERTIONS) check(atom in candidate.postponedAtoms) + + sink.yieldDiagnostic(UnsuccessfulCallableReferenceAtom) } else when (applicability) { CandidateApplicability.RESOLVED_NEED_PRESERVE_COMPATIBILITY -> sink.reportDiagnostic(LowerPriorityToPreserveCompatibilityDiagnostic) diff --git a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt index 6b02a9152e9..ae489fe290c 100644 --- a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt +++ b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt @@ -76,6 +76,8 @@ class NameForAmbiguousParameter( object InapplicableCandidate : ResolutionDiagnostic(INAPPLICABLE) +object UnsuccessfulCallableReferenceAtom : ResolutionDiagnostic(INAPPLICABLE) + object ErrorTypeInArguments : ResolutionDiagnostic(INAPPLICABLE) object HiddenCandidate : ResolutionDiagnostic(HIDDEN) diff --git a/compiler/testData/diagnostics/tests/annotations/annotationRenderingInTypes.fir.kt b/compiler/testData/diagnostics/tests/annotations/annotationRenderingInTypes.fir.kt index 1e5c44e7840..de88d1d6699 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationRenderingInTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationRenderingInTypes.fir.kt @@ -3,7 +3,7 @@ fun f1(x: String) {} fun f2(f: () -> Unit) {} -fun test1() = Unit): Unit")!>f2(::f1) +fun test1() = f2(::f1) @Target(AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.TYPE) diff --git a/compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.fir.kt b/compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.fir.kt index 0cf63308253..257dd95b438 100644 --- a/compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/adapted/noKFunctionForAdaptation.fir.kt @@ -3,12 +3,12 @@ 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 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 f0: Function0 = returnAdapter(::foo) val f1: Function0 = ::foo val f2: Function0 = if (dumpStrategy == "KotlinLike") ::foo else ::bar } diff --git a/compiler/testData/diagnostics/tests/callableReference/constraintFromLHSWithCorrectDirection.fir.kt b/compiler/testData/diagnostics/tests/callableReference/constraintFromLHSWithCorrectDirection.fir.kt index 33608a65ca8..eae0aa00f0d 100644 --- a/compiler/testData/diagnostics/tests/callableReference/constraintFromLHSWithCorrectDirection.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/constraintFromLHSWithCorrectDirection.fir.kt @@ -18,6 +18,6 @@ fun B.star(p: KProperty1<*, V>): B = TODO() fun B.test(){ foo(A::bla) bar(A::bla) - baz(A::bla) + baz(A::bla) star(A::bla) } diff --git a/compiler/testData/diagnostics/tests/callableReference/constraintFromLHSWithCorrectDirectionError.fir.kt b/compiler/testData/diagnostics/tests/callableReference/constraintFromLHSWithCorrectDirectionError.fir.kt index ff666a0dc55..6f84b03e6ff 100644 --- a/compiler/testData/diagnostics/tests/callableReference/constraintFromLHSWithCorrectDirectionError.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/constraintFromLHSWithCorrectDirectionError.fir.kt @@ -14,5 +14,5 @@ fun B.foo(p: KProperty1) {} class C : A fun B.test(){ - foo(C::bla) + foo(C::bla) } diff --git a/compiler/testData/diagnostics/tests/callableReference/expectedTypeAsSubtypeOfFunctionType.fir.kt b/compiler/testData/diagnostics/tests/callableReference/expectedTypeAsSubtypeOfFunctionType.fir.kt index 8f375237da6..86913a82ace 100644 --- a/compiler/testData/diagnostics/tests/callableReference/expectedTypeAsSubtypeOfFunctionType.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/expectedTypeAsSubtypeOfFunctionType.fir.kt @@ -7,6 +7,6 @@ fun takeIt(x: T, f: SubFunction) {} fun cr() {} fun test() { - takeIt(42, ::cr) + takeIt(42, ::cr) takeIt(42, { }) } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsTopLevel.fir.kt b/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsTopLevel.fir.kt index 20060820bfa..cb21ffcfa16 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsTopLevel.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsTopLevel.fir.kt @@ -25,7 +25,7 @@ class A { expectFunction0Unit(::foo) expectFunction0String(::foo) - expectFunction1Unit(::foo) - expectFunction1String(::foo) + expectFunction1Unit(::foo) + expectFunction1String(::foo) } } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/unresolved.fir.kt b/compiler/testData/diagnostics/tests/callableReference/function/unresolved.fir.kt index 241f87384cd..48228185038 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/unresolved.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/unresolved.fir.kt @@ -17,7 +17,7 @@ fun test2() { fun foo() {} Unresolved::foo - foo(Unresolved::foo) - foo(Unresolved::unresolved) + foo(Unresolved::foo) + foo(Unresolved::unresolved) ::unresolved } diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/dependOnArgumentType.fir.kt b/compiler/testData/diagnostics/tests/callableReference/generic/dependOnArgumentType.fir.kt index 81878fbe858..fc8eea48886 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/dependOnArgumentType.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/dependOnArgumentType.fir.kt @@ -16,14 +16,14 @@ fun bar(s: T) {} fun complex(t: T, f: (T) -> Unit) {} fun test1() { - foo(1, A::invokeLater) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE + foo(1, A::invokeLater) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE foo(1, ::bar) complex(1, ::bar) } fun test2(x: R) { - foo(x, A::invokeLater) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE + foo(x, A::invokeLater) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE foo(x, ::bar) complex(x, ::bar) diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/explicitTypeArguments.fir.kt b/compiler/testData/diagnostics/tests/callableReference/generic/explicitTypeArguments.fir.kt index efa93ce7aec..00fd1ed9da6 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/explicitTypeArguments.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/explicitTypeArguments.fir.kt @@ -13,7 +13,7 @@ fun Wrapper.baz(transform: (T) -> Unit): T = TODO() fun test() { takeFun(::foo) - takeFun(::fooInt) + takeFun(::fooInt) callFun>(::createWrapper) callFun>(::createWrapper) diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/genericExtensionFunction.fir.kt b/compiler/testData/diagnostics/tests/callableReference/generic/genericExtensionFunction.fir.kt index 416da3b8e88..5582063a049 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/genericExtensionFunction.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/genericExtensionFunction.fir.kt @@ -22,8 +22,8 @@ fun test1() { fun test2() { bar(Wrapper::fooReturnString).checkType { _>() } bar(Wrapper::fooReturnString).checkType { _>() } - bar(Wrapper::fooReturnString) - bar(Wrapper::fooReturnString) + bar(Wrapper::fooReturnString) + bar(Wrapper::fooReturnString) bar(Wrapper::fooTakeInt).checkType { _>() } bar(Wrapper::fooTakeInt).checkType { _>() } diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/resolutionWithGenericCallable.fir.kt b/compiler/testData/diagnostics/tests/callableReference/generic/resolutionWithGenericCallable.fir.kt index 3097f57b837..bd993580161 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/resolutionWithGenericCallable.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/resolutionWithGenericCallable.fir.kt @@ -17,5 +17,5 @@ fun bar(x: T, f: (T) -> Unit) {} fun test2() { bar(1, ::foo) bar("", ::foo) - bar(1.0, ::foo) + bar(1.0, ::foo) } diff --git a/compiler/testData/diagnostics/tests/callableReference/genericCallWithReferenceAgainstVararg.fir.kt b/compiler/testData/diagnostics/tests/callableReference/genericCallWithReferenceAgainstVararg.fir.kt index 71ad8ffd707..995bf4d0184 100644 --- a/compiler/testData/diagnostics/tests/callableReference/genericCallWithReferenceAgainstVararg.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/genericCallWithReferenceAgainstVararg.fir.kt @@ -4,7 +4,7 @@ fun foo(vararg ints: Int) {} fun test(i: IntArray) { myLet(i, ::foo) myLet(::foo) - myLet(::foo) + myLet(::foo) myLet(::foo) myLetExplicit1(::foo) myLetExplicit2(::foo) diff --git a/compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.fir.kt b/compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.fir.kt deleted file mode 100644 index f334a32c88f..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.fir.kt +++ /dev/null @@ -1,10 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER - -import kotlin.reflect.KProperty1 - -class TestClass(var prop: Int) -open class OtherClass -fun OtherClass.test(prop: KProperty1): Unit = throw Exception() -class OtherClass2: OtherClass() { - val result = test(TestClass::result) -} diff --git a/compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.kt b/compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.kt index 2354ecf0ba7..1452b0d0fcf 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER import kotlin.reflect.KProperty1 diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/adaptedReferenceAgainstReflectionType.fir.kt index e042c41bd70..07280bcb466 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/byGenericArgType.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/byGenericArgType.fir.kt index acbc18786ab..e760d3cd14a 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/byGenericArgType.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/byGenericArgType.fir.kt @@ -7,4 +7,4 @@ fun foo(s: String) {} val x1 = ofType<() -> Unit>(::foo) val x2 = ofType<(String) -> Unit>(::foo) -val x3 = ofType<(Int) -> Unit>(::foo) +val x3 = ofType<(Int) -> Unit>(::foo) diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/compatibilityWarningOnReferenceAgainstReflectiveType.fir.kt index f24ac33174d..7c0b8f8f939 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/diagnostics/tests/callableReference/resolve/kt35887_simple.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/kt35887_simple.fir.kt index 4d11a06d1b4..203670aacc0 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/kt35887_simple.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/kt35887_simple.fir.kt @@ -5,4 +5,4 @@ import kotlin.reflect.KProperty0 object A fun property0(property: KProperty0) = A -val K.key get() : A = property0(Map.Entry::key) // should be forbidden +val K.key get() : A = property0(Map.Entry::key) // should be forbidden diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/resolveCallableReferencesAfterAllSimpleArguments.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/resolveCallableReferencesAfterAllSimpleArguments.fir.kt index f0e0b5d4c87..69546dbdc88 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/resolveCallableReferencesAfterAllSimpleArguments.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/resolveCallableReferencesAfterAllSimpleArguments.fir.kt @@ -10,6 +10,6 @@ fun baz(e: T, f: (T) -> Unit) {} fun test(a: A, b: B) { // Note that diagnostic is always on callable references as they are resolved after simple arguments - baz(a, ::fooB) - bar(::fooB, a) + baz(a, ::fooB) + bar(::fooB, a) } diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/withGenericFun.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/withGenericFun.fir.kt index 6196d6cb1e1..bf21c82340b 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/withGenericFun.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/withGenericFun.fir.kt @@ -8,4 +8,4 @@ fun foo(s: String) {} val x1 = apply(1, ::foo) val x2 = apply("hello", ::foo) -val x3 = apply(true, ::foo) +val x3 = apply(true, ::foo) diff --git a/compiler/testData/diagnostics/tests/callableReference/unsupported/callableReferenceToLocalVariable.fir.kt b/compiler/testData/diagnostics/tests/callableReference/unsupported/callableReferenceToLocalVariable.fir.kt index c0d6ca08f37..52bb500a641 100644 --- a/compiler/testData/diagnostics/tests/callableReference/unsupported/callableReferenceToLocalVariable.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/unsupported/callableReferenceToLocalVariable.fir.kt @@ -3,7 +3,7 @@ fun a() { val x = 10 - foo(::x) + foo(::x) } fun foo(a: Any) {} diff --git a/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariable.fir.kt b/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariable.fir.kt index a5d4d4e6293..3639382638e 100644 --- a/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariable.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariable.fir.kt @@ -11,5 +11,5 @@ fun test(param: String) { val lambda = { -> } val g = ::lambda - eat(::param) + eat(::param) } diff --git a/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariableWithSubstitution.fir.kt b/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariableWithSubstitution.fir.kt index 79d8908578e..ba97ecae089 100644 --- a/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariableWithSubstitution.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariableWithSubstitution.fir.kt @@ -9,6 +9,6 @@ class Foo { fun main() { val f = Foo() val a: Int - get() = f.getValue(null, ::a) // no exception after fix + get() = f.getValue(null, ::a) // no exception after fix print(a) } diff --git a/compiler/testData/diagnostics/tests/callableReference/unsupported/parameterWithSubstitution.fir.kt b/compiler/testData/diagnostics/tests/callableReference/unsupported/parameterWithSubstitution.fir.kt index 88f7ab02b58..b60aa592018 100644 --- a/compiler/testData/diagnostics/tests/callableReference/unsupported/parameterWithSubstitution.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/unsupported/parameterWithSubstitution.fir.kt @@ -9,6 +9,6 @@ class Foo { fun main(x: Int) { val f = Foo() val a: Int - get() = f.getValue(null, ::x) // no exception after fix + get() = f.getValue(null, ::x) // no exception after fix print(a) } diff --git a/compiler/testData/diagnostics/tests/delegation/kt49477.fir.kt b/compiler/testData/diagnostics/tests/delegation/kt49477.fir.kt index 45014c3ecde..cedbdc38b5e 100644 --- a/compiler/testData/diagnostics/tests/delegation/kt49477.fir.kt +++ b/compiler/testData/diagnostics/tests/delegation/kt49477.fir.kt @@ -24,7 +24,7 @@ infix fun filter(filter: (R, Any?) -> Boolean): Delegate } class GitLabChangesProcessor: DatabaseEntity { - var buildProcessors by child_many( + var buildProcessors by child_many( GitLabBuildProcessor::class.java, GitLabBuildProcessor::processor ) diff --git a/compiler/testData/diagnostics/tests/delegation/kt49477Error.fir.kt b/compiler/testData/diagnostics/tests/delegation/kt49477Error.fir.kt index e99e8bdb576..a00df2948db 100644 --- a/compiler/testData/diagnostics/tests/delegation/kt49477Error.fir.kt +++ b/compiler/testData/diagnostics/tests/delegation/kt49477Error.fir.kt @@ -25,7 +25,7 @@ infix fun filter(filter: (R, Any?) -> Boolean): Delegate } class GitLabChangesProcessor: DatabaseEntity { - var buildProcessors by child_many( + var buildProcessors by child_many( GitLabBuildProcessor::class.java, GitLabBuildProcessor::processor ) diff --git a/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt b/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt index 4a470f16040..4ada5ae2a3c 100644 --- a/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt @@ -27,22 +27,22 @@ interface Foo { // CR on property with to receivers are forbidden fun test() { // with LHS and property - bar8(Foo::x1) - bar8(Foo::x1) - bar8(Foo::x1) + bar8(Foo::x1) + bar8(Foo::x1) + bar8(Foo::x1) // with LHS and mutable property - bar8(Foo::x2) - bar8(Foo::x2) - bar8(Foo::x2) + bar8(Foo::x2) + bar8(Foo::x2) + bar8(Foo::x2) // with LHS and propery + mutable property (mixed) - bar8(Foo::x3) - bar8(Foo::x3) - bar8(Foo::x3) - bar9(Foo::x3) - bar9(Foo::x3) - bar9(Foo::x3) + bar8(Foo::x3) + bar8(Foo::x3) + bar8(Foo::x3) + bar9(Foo::x3) + bar9(Foo::x3) + bar9(Foo::x3) } } @@ -114,14 +114,14 @@ fun main() { bar7(Foo::resolve) // OK // with LHS and sentension function expected type - bar10(Int::x1) // ERROR before the fix in NI + bar10(Int::x1) // ERROR before the fix in NI bar10(Int::x1) // OK bar10(Int::x1) // OK fun Int.ext() { // with LHS and sentension function expected type - bar10(::x1) // ERROR before the fix in NI - bar10(::x1) // OK - bar10(::x1) // OK + bar10(::x1) // ERROR before the fix in NI + bar10(::x1) // OK + bar10(::x1) // OK } } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt32862_none.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt32862_none.fir.kt index f1f3d017190..f144f960a93 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt32862_none.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt32862_none.fir.kt @@ -6,5 +6,5 @@ fun foo(i: Long) {} fun bar(f: (Boolean) -> Unit) {} fun test() { - bar(::foo) + bar(::foo) } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt34282.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt34282.fir.kt index c8c6d295544..13d9040ee94 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt34282.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt34282.fir.kt @@ -5,5 +5,5 @@ fun foo(x: Float) = 10f fun foo(x: String) = "" fun main() { - bar(::foo) // no report about unresolved callable reference for `foo` + bar(::foo) // no report about unresolved callable reference for `foo` } diff --git a/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.fir.kt b/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.fir.kt deleted file mode 100644 index aa0854e2744..00000000000 --- a/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.fir.kt +++ /dev/null @@ -1,7 +0,0 @@ -fun T.map(f: (T) -> U) = f(this) - -fun consume(s: String) {} - -fun test() { - consume(1.map(::foo)) -} diff --git a/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt b/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt index 338de3b205b..31685731a3a 100644 --- a/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt +++ b/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun T.map(f: (T) -> U) = f(this) fun consume(s: String) {} diff --git a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt index 6d29d8d137e..abfbd38167f 100644 --- a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt @@ -274,7 +274,7 @@ fun poll76() { } fun poll8() { - val inv = ::bar in setOf(::foo) + val inv = ::bar in setOf(::foo) inv() } @@ -284,7 +284,7 @@ fun poll81() { } fun poll82() { - val inv = ::bar3 in setOf(::foo3) + val inv = ::bar3 in setOf(::foo3) inv() } @@ -294,7 +294,7 @@ fun poll83() { } fun poll84() { - val inv = ::bar5 in setOf(::foo5) + val inv = ::bar5 in setOf(::foo5) inv } diff --git a/compiler/testData/diagnostics/tests/j+k/sam/referenceToSamFunctionAgainstExpectedType.fir.kt b/compiler/testData/diagnostics/tests/j+k/sam/referenceToSamFunctionAgainstExpectedType.fir.kt index 9e6142013b8..934f581a0cc 100644 --- a/compiler/testData/diagnostics/tests/j+k/sam/referenceToSamFunctionAgainstExpectedType.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/sam/referenceToSamFunctionAgainstExpectedType.fir.kt @@ -18,7 +18,7 @@ public class Inv { fun test(inv: Inv) { val m: ((String) -> String) -> Inv = inv::map - take(inv::map) + take(inv::map) } fun take(f: ((String) -> String) -> Inv) {} diff --git a/compiler/testData/diagnostics/tests/regressions/ea72837.fir.kt b/compiler/testData/diagnostics/tests/regressions/ea72837.fir.kt index fe4dad1f4b8..45ff901ec27 100644 --- a/compiler/testData/diagnostics/tests/regressions/ea72837.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/ea72837.fir.kt @@ -4,6 +4,6 @@ fun h(x: () -> Unit) = 1 fun foo() { f(::) - g(::) - h(::) + g(::) + h(::) } diff --git a/compiler/testData/diagnostics/tests/suspendConversion/basicSuspendConversionForCallableReference.fir.kt b/compiler/testData/diagnostics/tests/suspendConversion/basicSuspendConversionForCallableReference.fir.kt index 6592ddccb2d..3536c68318e 100644 --- a/compiler/testData/diagnostics/tests/suspendConversion/basicSuspendConversionForCallableReference.fir.kt +++ b/compiler/testData/diagnostics/tests/suspendConversion/basicSuspendConversionForCallableReference.fir.kt @@ -14,5 +14,5 @@ fun test() { foo2(42, ::bar2) foo2("str", ::bar2) - foo2(42, ::bar1) + foo2(42, ::bar1) } diff --git a/compiler/testData/diagnostics/tests/varargs/varargViewedAsArray.fir.kt b/compiler/testData/diagnostics/tests/varargs/varargViewedAsArray.fir.kt index ffa9ea0c94e..a370fdbd428 100644 --- a/compiler/testData/diagnostics/tests/varargs/varargViewedAsArray.fir.kt +++ b/compiler/testData/diagnostics/tests/varargs/varargViewedAsArray.fir.kt @@ -20,9 +20,9 @@ fun test() { useStringArray(::stringVararg) useIntArray(::numberVararg) usePrimitiveIntArray(::intVararg) - useIntArray(::intVararg) - useMixedStringArgs1(::stringVararg) - useMixedStringArgs2(::stringVararg) - useMixedStringArgs3(::stringVararg) - useTwoStringArrays(::stringVararg) + useIntArray(::intVararg) + useMixedStringArgs1(::stringVararg) + useMixedStringArgs2(::stringVararg) + useMixedStringArgs3(::stringVararg) + useTwoStringArrays(::stringVararg) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.fir.kt index e87e181dacf..06b067e5d90 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.fir.kt @@ -5,8 +5,8 @@ class Impl : Inv class Scope(private val implClass: j.Class) { fun foo(c: Collection) { val hm = c.asSequence() - .filter(implClass::isInstance) - .map(implClass::cast) + .filter(implClass::isInstance) + .map(implClass::cast) .toSet() } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/suspendConversionForCallableReferences.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/suspendConversionForCallableReferences.fir.kt index 08f034e8c9b..5360e356001 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/suspendConversionForCallableReferences.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/suspendConversionForCallableReferences.fir.kt @@ -10,7 +10,7 @@ suspend fun String.id(): String = this fun box() { val x = "f" builder { - go1(x::id) - go2(x::id) + go1(x::id) + go2(x::id) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/callableReferenceToASuspendFunction.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/callableReferenceToASuspendFunction.fir.kt index a2d3bc3a55e..56be7f1b012 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/callableReferenceToASuspendFunction.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/callableReferenceToASuspendFunction.fir.kt @@ -14,8 +14,8 @@ suspend fun bar(x: Int) {} fun test() { test0(::foo) - test1(::foo) + test1(::foo) - test0(::bar) + test0(::bar) test1(::bar) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/callableReferenceOnParameter.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/callableReferenceOnParameter.fir.kt index 35a458694cb..48174dc95bf 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/callableReferenceOnParameter.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/callableReferenceOnParameter.fir.kt @@ -3,6 +3,6 @@ internal class Z { val map = HashMap() inline fun compute(key: String, producer: () -> String): String { - return map.getOrPut(key, ::producer) + return map.getOrPut(key, ::producer) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/delegates/kt50994.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/delegates/kt50994.fir.kt index 88b67ef10c0..7a0ea532842 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/delegates/kt50994.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/delegates/kt50994.fir.kt @@ -9,7 +9,7 @@ class ProcessorWithParent : Entity { } class ProcessorWithChildren : Entity { - var processors by children(ProcessorWithParent::class.java, ProcessorWithParent::processor) + var processors by children(ProcessorWithParent::class.java, ProcessorWithParent::processor) } class Processor2WithParent : Entity { diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/bidirectional-resolution-for-callable-calls/p-3/neg/1.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/bidirectional-resolution-for-callable-calls/p-3/neg/1.1.fir.kt index a00bf837e49..0148704fe37 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/bidirectional-resolution-for-callable-calls/p-3/neg/1.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/bidirectional-resolution-for-callable-calls/p-3/neg/1.1.fir.kt @@ -25,7 +25,7 @@ class Case1() { } fun case() { - Companion(::x) + Companion(::x) } val x = "" @@ -41,7 +41,7 @@ class Case2() { } fun case() { - Companion(::x) + Companion(::x) } val x = C()