diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java index 5a2543620c5..124824f3f63 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java @@ -2827,11 +2827,21 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/references/integerLiteralInLhs.kt"); } + @TestMetadata("leakedImplicitType.kt") + public void testLeakedImplicitType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/leakedImplicitType.kt"); + } + @TestMetadata("referenceToExtension.kt") public void testReferenceToExtension() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToExtension.kt"); } + @TestMetadata("referenceToField.kt") + public void testReferenceToField() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToField.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/references/simple.kt"); diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/errCallable.fir.txt b/compiler/fir/analysis-tests/testData/resolve/expresssions/errCallable.fir.txt index 4943d4d9a9f..6cd7f7ee287 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/errCallable.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/errCallable.fir.txt @@ -18,10 +18,10 @@ FILE: errCallable.kt } public final fun foo(): R|kotlin/Unit| { - lval x: = ::# + lval x: R|ERROR CLASS: Unresolved reference: Nested| = ::# } } public final fun R|Your|.foo(): R|kotlin/Unit| { - lval x: = ::# + lval x: R|ERROR CLASS: Unresolved reference: Nested| = ::# } diff --git a/compiler/fir/analysis-tests/testData/resolve/references/leakedImplicitType.fir.txt b/compiler/fir/analysis-tests/testData/resolve/references/leakedImplicitType.fir.txt new file mode 100644 index 00000000000..cea18ce088e --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/references/leakedImplicitType.fir.txt @@ -0,0 +1,25 @@ +FILE: leakedImplicitType.kt + public final class Foo : R|kotlin/Any| { + public constructor(): R|Foo| { + super() + } + + public final fun bar(): R|kotlin/Unit| { + } + + public final fun f(): R|ERROR CLASS: Unresolved reference: bar| { + ^f #()::# + } + + } + public abstract interface IA : R|kotlin/Any| { + } + public abstract interface IB : R|IA| { + } + public final fun R|IA|.extFun(x: R|IB|): R|kotlin/Unit| { + } + public final fun R|IB|.extFun(x: R|IA|): R|kotlin/Unit| { + } + public final fun testWithExpectedType(): R|kotlin/Unit| { + lval extFun_AA_B: R|IA.(IA) -> kotlin/Unit| = Q|IB|::# + } diff --git a/compiler/fir/analysis-tests/testData/resolve/references/leakedImplicitType.kt b/compiler/fir/analysis-tests/testData/resolve/references/leakedImplicitType.kt new file mode 100644 index 00000000000..50284e07ef8 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/references/leakedImplicitType.kt @@ -0,0 +1,18 @@ +// ISSUE: KT-46072 + +// Case 1 +class Foo { + fun bar() {} + fun f() = Unresolved()::bar // Type of Unresolved()::bar is implicit +} + +// Case 2 +interface IA +interface IB : IA + +fun IA.extFun(x: IB) {} +fun IB.extFun(x: IA) {} + +fun testWithExpectedType() { + val extFun_AA_B: IA.(IA) -> Unit = IB::extFun // extFun is unresolved, type of IB::extFun is implicit +} diff --git a/compiler/fir/analysis-tests/testData/resolve/references/referenceToExtension.fir.txt b/compiler/fir/analysis-tests/testData/resolve/references/referenceToExtension.fir.txt index 4f827884899..1306b0d84f4 100644 --- a/compiler/fir/analysis-tests/testData/resolve/references/referenceToExtension.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/references/referenceToExtension.fir.txt @@ -40,8 +40,8 @@ FILE: referenceToExtension.kt } public final fun test_2(): R|kotlin/Unit| { - lval extensionValRef: = Q|GenericTest.B|::# - lval extensionFunRef: = Q|GenericTest.B|::# + lval extensionValRef: R|ERROR CLASS: Unresolved reference: extensionVal| = Q|GenericTest.B|::# + lval extensionFunRef: R|ERROR CLASS: Unresolved reference: extensionFun| = Q|GenericTest.B|::# } } diff --git a/compiler/fir/analysis-tests/testData/resolve/references/referenceToField.fir.txt b/compiler/fir/analysis-tests/testData/resolve/references/referenceToField.fir.txt new file mode 100644 index 00000000000..c65c3d19629 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/references/referenceToField.fir.txt @@ -0,0 +1,13 @@ +FILE: referenceToField.kt + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + public final val x: R|kotlin/Int| = Int(1) + public get(): R|kotlin/Int| { + ::F|/A.x| + ^ this@R|/A|.F|/A.x| + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/references/referenceToField.kt b/compiler/fir/analysis-tests/testData/resolve/references/referenceToField.kt new file mode 100644 index 00000000000..b91e8cbeaea --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/references/referenceToField.kt @@ -0,0 +1,7 @@ +class A { + val x: Int = 1 + get() { + ::field + return field + } +} diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.fir.txt index 96bc8fde8aa..c205a65cb1e 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.fir.txt @@ -13,7 +13,7 @@ FILE: beyoundCalls.kt } public final fun foo(): R|kotlin/Unit| { lval x: R|(kotlin/String) -> kotlin/Int| = ::R|/bar| - lval y: = ::# + lval y: R|ERROR CLASS: Ambiguity: bar, [/bar, /bar]| = ::# lval z: R|kotlin/reflect/KFunction1| = ::R|/baz| lval w: R|(kotlin/String) -> kotlin/Int| = ::R|/foobaz| ::R|/baz| diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.kt index 755616f109a..0ffa0b95280 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.kt @@ -6,7 +6,7 @@ fun foobaz(x: T): R = TODO() fun foo() { val x: (String) -> Int = ::bar - val y = ::bar + val y = ::bar val z = ::baz val w: (String) -> Int = ::foobaz diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/ambiguityWhenNoApplicableCallableReferenceCandidate.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/ambiguityWhenNoApplicableCallableReferenceCandidate.fir.txt index 41dfc57cd75..4f867ede5e3 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/ambiguityWhenNoApplicableCallableReferenceCandidate.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/ambiguityWhenNoApplicableCallableReferenceCandidate.fir.txt @@ -6,5 +6,5 @@ FILE: ambiguityWhenNoApplicableCallableReferenceCandidate.kt public final fun bar(f: R|(T) -> kotlin/Unit|): R|kotlin/Unit| { } public final fun test(): R|kotlin/Unit| { - R|/bar|(::#) + R|/bar|(::#) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/ambiguityWhenNoApplicableCallableReferenceCandidate.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/ambiguityWhenNoApplicableCallableReferenceCandidate.kt index 1658c58ff58..0808239c646 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/ambiguityWhenNoApplicableCallableReferenceCandidate.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/ambiguityWhenNoApplicableCallableReferenceCandidate.kt @@ -4,5 +4,5 @@ fun foo(y: String) {} fun bar(f: (T) -> Unit) {} fun test() { - bar(::foo) + bar(::foo) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.fir.txt index 7a9ae0d54e8..45c24a82608 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.fir.txt @@ -37,7 +37,7 @@ FILE: chooseCallableReferenceDependingOnInferredReceiver.kt lval a: R|A| = R|/bar|(::R|/A.foo|) lval b: R|B| = R|/bar|(::R|/B.foo|) lval t3: R|B| = R|/bar|(::R|/B.baz|) - ^ R|/bar|(::#) + ^ R|/bar|(::#) } ) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.kt index 422a8629932..d1696c178a3 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.kt @@ -25,7 +25,7 @@ fun test() { val t3 = bar(::baz) - bar(::foo) + bar(::foo) } } } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.fir.txt index 9ea7df9597b..33bbc9f2684 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.fir.txt @@ -21,5 +21,5 @@ FILE: eagerAndPostponedCallableReferences.kt lval a4: R|B| = R|/foo|(::R|/multiple|, ::R|/singleB|) lval a5: R|A| = R|/foo|(::R|/singleA|, ::R|/singleA|) lval a6: R|it(A & B)| = R|/foo|(::R|/singleA|, ::R|/singleB|) - R|/foo|(::#, ::#) + R|/foo|(::#, ::#) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.kt index b12818aff18..70a8d59dc6d 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/eagerAndPostponedCallableReferences.kt @@ -22,5 +22,5 @@ fun test() { val a6 = foo(::singleA, ::singleB) - foo(::multiple, ::multiple) + foo(::multiple, ::multiple) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/moreSpecificAmbiguousExtensions.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/moreSpecificAmbiguousExtensions.fir.txt index 8365898a4b8..ce433eb32a7 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/moreSpecificAmbiguousExtensions.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/moreSpecificAmbiguousExtensions.fir.txt @@ -9,12 +9,12 @@ FILE: moreSpecificAmbiguousExtensions.kt } public final fun test(): R|kotlin/Unit| { lval extFun1: R|@ExtensionFunctionType kotlin/reflect/KFunction2| = Q|IA|::R|/extFun| - lval extFun2: = Q|IB|::# + lval extFun2: R|ERROR CLASS: Ambiguity: extFun, [/extFun, /extFun]| = Q|IB|::# } public final fun testWithExpectedType(): R|kotlin/Unit| { lval extFun_AB_A: R|IA.(IB) -> kotlin/Unit| = Q|IA|::R|/extFun| lval extFun_AA_B: R|IA.(IA) -> kotlin/Unit| = Q|IB|::# lval extFun_BB_A: R|IB.(IB) -> kotlin/Unit| = Q|IA|::R|/extFun| lval extFun_BA_B: R|IB.(IA) -> kotlin/Unit| = Q|IB|::R|/extFun| - lval extFun_BB_B: R|IB.(IB) -> kotlin/Unit| = Q|IB|::# + lval extFun_BB_B: R|IB.(IB) -> kotlin/Unit| = Q|IB|::# } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/moreSpecificAmbiguousExtensions.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/moreSpecificAmbiguousExtensions.kt index 2abbd279642..88890ac51ec 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/moreSpecificAmbiguousExtensions.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/moreSpecificAmbiguousExtensions.kt @@ -6,7 +6,7 @@ fun IB.extFun(x: IA) {} fun test() { val extFun1 = IA::extFun - val extFun2 = IB::extFun + val extFun2 = IB::extFun } fun testWithExpectedType() { @@ -15,5 +15,5 @@ fun testWithExpectedType() { val extFun_AA_B: IA.(IA) -> Unit = IB::extFun val extFun_BB_A: IB.(IB) -> Unit = IA::extFun val extFun_BA_B: IB.(IA) -> Unit = IB::extFun - val extFun_BB_B: IB.(IB) -> Unit = IB::extFun + val extFun_BB_B: IB.(IB) -> Unit = IB::extFun } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.fir.txt index a5f610ab48b..4aeba52b5ad 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.fir.txt @@ -10,5 +10,5 @@ FILE: manyInnermanyOuterCandidatesAmbiguity.kt ^bar Int(1) } public final fun main(): R|kotlin/Unit| { - #(::#) + #(::#) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.kt index 4c9ebd28d02..6d1c37ad927 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.kt @@ -6,5 +6,5 @@ fun bar(): Int = 1 fun bar(x: String): Int = 1 fun main() { - foo(::bar) + foo(::bar) } diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index 91600c79a39..b2dd83f9227 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -3199,12 +3199,24 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/references/integerLiteralInLhs.kt"); } + @Test + @TestMetadata("leakedImplicitType.kt") + public void testLeakedImplicitType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/leakedImplicitType.kt"); + } + @Test @TestMetadata("referenceToExtension.kt") public void testReferenceToExtension() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToExtension.kt"); } + @Test + @TestMetadata("referenceToField.kt") + public void testReferenceToField() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToField.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index 7f1ff18e0ea..810faaf301e 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -3235,12 +3235,24 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/references/integerLiteralInLhs.kt"); } + @Test + @TestMetadata("leakedImplicitType.kt") + public void testLeakedImplicitType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/leakedImplicitType.kt"); + } + @Test @TestMetadata("referenceToExtension.kt") public void testReferenceToExtension() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToExtension.kt"); } + @Test + @TestMetadata("referenceToField.kt") + public void testReferenceToField() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToField.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt index 0ed3b8214b7..03da23495d1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -214,7 +214,12 @@ class FirCallResolver( when { referencedSymbol is FirClassLikeSymbol<*> -> { - return components.buildResolvedQualifierForClass(referencedSymbol, nameReference.source, qualifiedAccess.typeArguments, diagnostic) + return components.buildResolvedQualifierForClass( + referencedSymbol, + nameReference.source, + qualifiedAccess.typeArguments, + diagnostic + ) } referencedSymbol is FirTypeParameterSymbol && referencedSymbol.fir.isReified -> { return buildResolvedReifiedParameterReference { @@ -260,7 +265,8 @@ class FirCallResolver( ) } val bestCandidates = result.bestCandidates() - val noSuccessfulCandidates = !result.currentApplicability.isSuccess + val applicability = result.currentApplicability + val noSuccessfulCandidates = !applicability.isSuccess val reducedCandidates = if (noSuccessfulCandidates) { bestCandidates.toSet() } else { @@ -271,10 +277,24 @@ class FirCallResolver( when { noSuccessfulCandidates -> { + val errorReference = buildErrorReference( + info, + ConeUnresolvedReferenceError(info.name), + callableReferenceAccess.source + ) + resolvedCallableReferenceAtom.resultingReference = errorReference return false } reducedCandidates.size > 1 -> { - if (resolvedCallableReferenceAtom.hasBeenPostponed) return false + if (resolvedCallableReferenceAtom.hasBeenPostponed) { + val errorReference = buildErrorReference( + info, + ConeAmbiguityError(info.name, applicability, reducedCandidates.map { it.symbol }), + callableReferenceAccess.source + ) + resolvedCallableReferenceAtom.resultingReference = errorReference + return false + } resolvedCallableReferenceAtom.hasBeenPostponed = true return true } @@ -283,11 +303,19 @@ class FirCallResolver( val chosenCandidate = reducedCandidates.single() constraintSystemBuilder.runTransaction { chosenCandidate.outerConstraintBuilderEffect!!(this) - true } - resolvedCallableReferenceAtom.resultingCandidate = Pair(chosenCandidate, result.currentApplicability) + val reference = createResolvedNamedReference( + callableReferenceAccess.calleeReference, + info.name, + info, + reducedCandidates, + applicability, + createResolvedReferenceWithoutCandidateForLocalVariables = false + ) + resolvedCallableReferenceAtom.resultingReference = reference + resolvedCallableReferenceAtom.resultingTypeForCallableReference = chosenCandidate.resultingTypeForCallableReference return true } @@ -384,8 +412,7 @@ class FirCallResolver( callInfo, if (annotationClassSymbol != null) ConeIllegalAnnotationError(reference.name) else ConeUnresolvedNameError(reference.name), - reference.source, - reference.name + reference.source ) } @@ -491,21 +518,20 @@ class FirCallResolver( candidates: Collection, applicability: CandidateApplicability, explicitReceiver: FirExpression? = null, + createResolvedReferenceWithoutCandidateForLocalVariables: Boolean = true ): FirNamedReference { val source = reference.source return when { candidates.isEmpty() -> buildErrorReference( callInfo, ConeUnresolvedNameError(name), - source, - name + source ) candidates.size > 1 -> buildErrorReference( callInfo, ConeAmbiguityError(name, applicability, candidates.map { it.symbol }), - source, - name + source ) !applicability.isSuccess -> { @@ -514,7 +540,13 @@ class FirCallResolver( CandidateApplicability.HIDDEN -> ConeHiddenCandidateError(candidate.symbol) else -> ConeInapplicableCandidateError(applicability, candidate) } - buildErrorReference(source, candidate, diagnostic) + createErrorReferenceWithExistingCandidate( + candidate, + diagnostic, + source, + transformer.resolutionContext, + components.resolutionStageRunner + ) } else -> { @@ -527,17 +559,25 @@ class FirCallResolver( resolvedSymbol = coneSymbol } } - if (explicitReceiver?.typeRef?.coneTypeSafe() == null) { - if (coneSymbol is FirVariableSymbol) { - if (coneSymbol !is FirPropertySymbol || - (coneSymbol.fir as FirMemberDeclaration).typeParameters.isEmpty() - ) { - return buildResolvedNamedReference { - this.source = source - this.name = name - resolvedSymbol = coneSymbol - } - } + /* + * This `if` is an optimization for local variables and properties without type parameters + * Since they have no type variables, so we can don't run completion on them at all and create + * resolved reference immediately + * + * But for callable reference resolution we should keep candidate, because it was resolved + * with special resolution stages, which saved in candidate additional reference info, + * like `resultingTypeForCallableReference` + */ + if ( + createResolvedReferenceWithoutCandidateForLocalVariables && + explicitReceiver?.typeRef?.coneTypeSafe() == null && + coneSymbol is FirVariableSymbol && + (coneSymbol !is FirPropertySymbol || (coneSymbol.fir as FirMemberDeclaration).typeParameters.isEmpty()) + ) { + return buildResolvedNamedReference { + this.source = source + this.name = name + resolvedSymbol = coneSymbol } } FirNamedReferenceWithCandidate(source, name, candidate) @@ -548,22 +588,14 @@ class FirCallResolver( private fun buildErrorReference( callInfo: CallInfo, diagnostic: ConeDiagnostic, - source: FirSourceElement?, - name: Name + source: FirSourceElement? ): FirErrorReferenceWithCandidate { - val candidate = CandidateFactory(transformer.resolutionContext, callInfo).createErrorCandidate(callInfo, diagnostic) - components.resolutionStageRunner.processCandidate(candidate, transformer.resolutionContext, stopOnFirstError = false) - return FirErrorReferenceWithCandidate(source, name, candidate, diagnostic) - } - - private fun buildErrorReference( - source: FirSourceElement?, - candidate: Candidate, - diagnostic: ConeDiagnostic - ): FirErrorReferenceWithCandidate { - if (!candidate.fullyAnalyzed) { - components.resolutionStageRunner.processCandidate(candidate, transformer.resolutionContext, stopOnFirstError = false) - } - return FirErrorReferenceWithCandidate(source, candidate.callInfo.name, candidate, diagnostic) + return createErrorReferenceWithErrorCandidate( + callInfo, + diagnostic, + source, + transformer.resolutionContext, + components.resolutionStageRunner + ) } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/errorCandidateUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/errorCandidateUtils.kt new file mode 100644 index 00000000000..44206f02f95 --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/errorCandidateUtils.kt @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.resolve + +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic +import org.jetbrains.kotlin.fir.resolve.calls.* + + +fun createErrorReferenceWithErrorCandidate( + callInfo: CallInfo, + diagnostic: ConeDiagnostic, + source: FirSourceElement?, + resolutionContext: ResolutionContext, + resolutionStageRunner: ResolutionStageRunner +): FirErrorReferenceWithCandidate { + return FirErrorReferenceWithCandidate( + source, + callInfo.name, + resolutionStageRunner.createErrorCandidate(callInfo, resolutionContext, diagnostic), + diagnostic + ) +} + +fun createErrorReferenceWithExistingCandidate( + candidate: Candidate, + diagnostic: ConeDiagnostic, + source: FirSourceElement?, + resolutionContext: ResolutionContext, + resolutionStageRunner: ResolutionStageRunner, +): FirErrorReferenceWithCandidate { + resolutionStageRunner.fullyProcessCandidate(candidate, resolutionContext) + return FirErrorReferenceWithCandidate(source, candidate.callInfo.name, candidate, diagnostic) +} + +fun ResolutionStageRunner.createErrorCandidate( + callInfo: CallInfo, + resolutionContext: ResolutionContext, + diagnostic: ConeDiagnostic +): Candidate { + val candidate = CandidateFactory(resolutionContext, callInfo).createErrorCandidate(callInfo, diagnostic) + processCandidate(candidate, resolutionContext, stopOnFirstError = false) + return candidate +} + +fun ResolutionStageRunner.fullyProcessCandidate(candidate: Candidate, resolutionContext: ResolutionContext) { + if (!candidate.fullyAnalyzed) { + processCandidate(candidate, resolutionContext, stopOnFirstError = false) + } +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt index 87b58871a00..bc470b362a7 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt @@ -16,13 +16,12 @@ import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedReferenceError import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.transformers.StoreNameReference import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzerContext import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder import org.jetbrains.kotlin.resolve.calls.inference.model.CoroutinePosition import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition -import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability -import org.jetbrains.kotlin.resolve.calls.tower.isSuccess import org.jetbrains.kotlin.types.model.StubTypeMarker import org.jetbrains.kotlin.types.model.TypeVariableMarker import org.jetbrains.kotlin.types.model.freshTypeConstructor @@ -78,27 +77,29 @@ class PostponedArgumentsAnalyzer( resolutionContext.bodyResolveContext.dropCallableReferenceContext(callableReferenceAccess) - val (resultingCandidate, applicability) = atom.resultingCandidate - ?: Pair(null, CandidateApplicability.INAPPLICABLE) - - val namedReference = when { - resultingCandidate == null || !applicability.isSuccess -> - buildErrorNamedReference { - source = callableReferenceAccess.source - diagnostic = ConeUnresolvedReferenceError(callableReferenceAccess.calleeReference.name) - } - else -> FirNamedReferenceWithCandidate(callableReferenceAccess.source, callableReferenceAccess.calleeReference.name, resultingCandidate) + val namedReference = atom.resultingReference ?: buildErrorNamedReference { + source = callableReferenceAccess.source + diagnostic = ConeUnresolvedReferenceError(callableReferenceAccess.calleeReference.name) } callableReferenceAccess.transformCalleeReference( StoreNameReference, namedReference ).apply { - if (resultingCandidate != null) { - val resolvedTypeRef = buildResolvedTypeRef { type = resultingCandidate.resultingTypeForCallableReference!! } - replaceTypeRef(resolvedTypeRef) - resolutionContext.session.lookupTracker?.recordTypeResolveAsLookup(resolvedTypeRef, source, null) + val typeForCallableReference = atom.resultingTypeForCallableReference + val resolvedTypeRef = when { + typeForCallableReference != null -> buildResolvedTypeRef { + type = typeForCallableReference + } + namedReference is FirErrorReferenceWithCandidate -> buildErrorTypeRef { + diagnostic = namedReference.diagnostic + } + else -> buildErrorTypeRef { + diagnostic = ConeUnresolvedReferenceError(callableReferenceAccess.calleeReference.name) + } } + replaceTypeRef(resolvedTypeRef) + resolutionContext.session.lookupTracker?.recordTypeResolveAsLookup(resolvedTypeRef, source, null) } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedAtoms.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedAtoms.kt index 2eed8d98f7f..bd42884e594 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedAtoms.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedAtoms.kt @@ -9,16 +9,16 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess import org.jetbrains.kotlin.fir.expressions.FirStatement +import org.jetbrains.kotlin.fir.references.FirNamedReference import org.jetbrains.kotlin.fir.resolve.DoubleColonLHS import org.jetbrains.kotlin.fir.resolve.calls.Candidate -import org.jetbrains.kotlin.name.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl +import org.jetbrains.kotlin.name.StandardClassIds import org.jetbrains.kotlin.resolve.calls.model.LambdaWithTypeVariableAsExpectedTypeMarker import org.jetbrains.kotlin.resolve.calls.model.PostponedCallableReferenceMarker import org.jetbrains.kotlin.resolve.calls.model.PostponedResolvedAtomMarker -import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability import org.jetbrains.kotlin.types.model.KotlinTypeMarker // --------------------------- Variables --------------------------- @@ -121,7 +121,8 @@ class ResolvedCallableReferenceAtom( val mightNeedAdditionalResolution get() = !hasBeenResolvedOnce || hasBeenPostponed - var resultingCandidate: Pair? = null + var resultingReference: FirNamedReference? = null + var resultingTypeForCallableReference: ConeKotlinType? = null override val inputTypes: Collection get() { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt index 7f45f52f159..461f7696673 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt @@ -327,15 +327,24 @@ class FirCallCompletionResultsWriterTransformer( callableReferenceAccess.replaceTypeArguments(typeArguments) session.lookupTracker?.recordTypeResolveAsLookup(resultType, typeRef.source ?: callableReferenceAccess.source, null) - return callableReferenceAccess.transformCalleeReference( - StoreCalleeReference, - buildResolvedCallableReference { + val resolvedReference = when (calleeReference) { + is FirErrorReferenceWithCandidate -> buildErrorNamedReference { + source = calleeReference.source + diagnostic = calleeReference.diagnostic + candidateSymbol = calleeReference.candidateSymbol + } + else -> buildResolvedCallableReference { source = calleeReference.source name = calleeReference.name resolvedSymbol = calleeReference.candidateSymbol inferredTypeArguments.addAll(computeTypeArgumentTypes(calleeReference.candidate)) mappedArguments = subCandidate.callableReferenceAdaptation?.mappedArguments ?: emptyMap() - }, + } + } + + return callableReferenceAccess.transformCalleeReference( + StoreCalleeReference, + resolvedReference, ).transformDispatchReceiver(StoreReceiver, subCandidate.dispatchReceiverExpression()) .transformExtensionReceiver(StoreReceiver, subCandidate.extensionReceiverExpression()) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt index 39bccda4581..aebb2cd17cd 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.resolve.transformers import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.resolve.createErrorReferenceWithExistingCandidate import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.builder.FirSimpleFunctionBuilder import org.jetbrains.kotlin.fir.declarations.builder.buildTypeParameter @@ -17,11 +18,10 @@ import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.builder.buildArgumentList import org.jetbrains.kotlin.fir.expressions.builder.buildFunctionCall import org.jetbrains.kotlin.fir.references.FirReference -import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference import org.jetbrains.kotlin.fir.references.impl.FirStubReference import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents import org.jetbrains.kotlin.fir.resolve.calls.* -import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError +import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeInapplicableCandidateError import org.jetbrains.kotlin.fir.resolvedTypeFromPrototype import org.jetbrains.kotlin.name.CallableId import org.jetbrains.kotlin.fir.symbols.SyntheticCallableId @@ -65,7 +65,7 @@ class FirSyntheticCallGenerator( argumentList, SyntheticCallableId.WHEN.callableName, context = context - ) ?: return null // TODO + ) return whenExpression.transformCalleeReference(UpdateReference, reference) } @@ -89,7 +89,7 @@ class FirSyntheticCallGenerator( argumentList, SyntheticCallableId.TRY.callableName, context = context - ) ?: return null // TODO + ) return tryExpression.transformCalleeReference(UpdateReference, reference) } @@ -104,7 +104,7 @@ class FirSyntheticCallGenerator( checkNotNullCall.argumentList, SyntheticCallableId.CHECK_NOT_NULL.callableName, context = context - ) ?: return null // TODO + ) return checkNotNullCall.transformCalleeReference(UpdateReference, reference) } @@ -122,7 +122,7 @@ class FirSyntheticCallGenerator( argumentList, SyntheticCallableId.ELVIS_NOT_NULL.callableName, context = context - ) ?: return null + ) return elvisExpression.transformCalleeReference(UpdateReference, reference) } @@ -142,12 +142,6 @@ class FirSyntheticCallGenerator( SyntheticCallableId.ID.callableName, CallKind.SyntheticIdForCallableReferencesResolution, context - ) ?: return callableReferenceAccess.transformCalleeReference( - StoreCalleeReference, - buildErrorNamedReference { - source = callableReferenceAccess.source - diagnostic = ConeUnresolvedNameError(callableReferenceAccess.calleeReference.name) - } ) val fakeCallElement = buildFunctionCall { calleeReference = reference @@ -165,12 +159,18 @@ class FirSyntheticCallGenerator( name: Name, callKind: CallKind = CallKind.SyntheticSelect, context: ResolutionContext - ): FirNamedReferenceWithCandidate? { + ): FirNamedReferenceWithCandidate { val callInfo = generateCallInfo(callSite, name, argumentList, callKind) val candidate = generateCandidate(callInfo, function, context) val applicability = components.resolutionStageRunner.processCandidate(candidate, context) if (applicability <= CandidateApplicability.INAPPLICABLE) { - return null + return createErrorReferenceWithExistingCandidate( + candidate, + ConeInapplicableCandidateError(applicability, candidate), + source = null, + context, + components.resolutionStageRunner + ) } return FirNamedReferenceWithCandidate(null, name, candidate) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index 2469c4ec843..55519c25b98 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -701,26 +701,21 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform } } - val callableReferenceAccessWithTransformedLHS = - if (transformedLHS != null) - callableReferenceAccess.transformExplicitReceiver(StoreReceiver, transformedLHS) - else - callableReferenceAccess + transformedLHS?.let { callableReferenceAccess.replaceExplicitReceiver(transformedLHS) } if (data !is ResolutionMode.ContextDependent /* ContextDependentDelegate is Ok here */) { val resolvedReference = components.syntheticCallGenerator.resolveCallableReferenceWithSyntheticOuterCall( callableReferenceAccess, data.expectedType, resolutionContext, ) ?: callableReferenceAccess - dataFlowAnalyzer.exitCallableReference(resolvedReference) return resolvedReference } context.storeCallableReferenceContext(callableReferenceAccess) - dataFlowAnalyzer.exitCallableReference(callableReferenceAccessWithTransformedLHS) - return callableReferenceAccessWithTransformedLHS + dataFlowAnalyzer.exitCallableReference(callableReferenceAccess) + return callableReferenceAccess } override fun transformGetClassCall(getClassCall: FirGetClassCall, data: ResolutionMode): FirStatement { diff --git a/compiler/testData/diagnostics/tests/callableReference/function/ambiguityTopLevelVsTopLevel.fir.kt b/compiler/testData/diagnostics/tests/callableReference/function/ambiguityTopLevelVsTopLevel.fir.kt index c5bbfb426ce..c9732474f75 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/ambiguityTopLevelVsTopLevel.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/ambiguityTopLevelVsTopLevel.fir.kt @@ -3,7 +3,7 @@ fun foo(x: Int, y: Any) = x fun foo(x: Any, y: Int) = y fun main() { - ::foo + ::foo val fooRef: (Int, Any) -> Unit = ::foo } diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/kt11075.fir.kt b/compiler/testData/diagnostics/tests/callableReference/generic/kt11075.fir.kt index ea2a7c6a71b..23bfd874a21 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/kt11075.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/kt11075.fir.kt @@ -6,5 +6,5 @@ object TestCallableReferences { fun test0(): (String) -> String = TestCallableReferences::foo - fun test1(): (List) -> List = TestCallableReferences::foo + fun test1(): (List) -> List = TestCallableReferences::foo } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/backingField.fir.kt b/compiler/testData/diagnostics/tests/callableReference/property/backingField.fir.kt deleted file mode 100644 index fb88458b47b..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/property/backingField.fir.kt +++ /dev/null @@ -1,7 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_EXPRESSION - -val i: Int = 10 - get() { - ::field - return field - } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/backingField.kt b/compiler/testData/diagnostics/tests/callableReference/property/backingField.kt index c0667c8be31..df609f877af 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/backingField.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/backingField.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_EXPRESSION val i: Int = 10 diff --git a/compiler/testData/diagnostics/tests/callableReference/referenceToCompanionObjectMemberViaClassNameCompatibility.fir.kt b/compiler/testData/diagnostics/tests/callableReference/referenceToCompanionObjectMemberViaClassNameCompatibility.fir.kt index 1a2786cf95f..ca6fce68c13 100644 --- a/compiler/testData/diagnostics/tests/callableReference/referenceToCompanionObjectMemberViaClassNameCompatibility.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/referenceToCompanionObjectMemberViaClassNameCompatibility.fir.kt @@ -22,7 +22,7 @@ fun B.foo(): Double = 0.0 fun call(a: Any) {} fun testA(a: A) { - call(A::foo) + call(A::foo) call(A.Companion::foo) } diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWhenNoApplicableCallableReferenceCandidate.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWhenNoApplicableCallableReferenceCandidate.fir.kt index 8666eea3136..8cc923c4142 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWhenNoApplicableCallableReferenceCandidate.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWhenNoApplicableCallableReferenceCandidate.fir.kt @@ -7,5 +7,5 @@ fun foo(y: String) {} fun bar(f: (T) -> Unit) {} fun test() { - bar(::foo) + bar(::foo) } diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWithBoundExtensionReceiver.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWithBoundExtensionReceiver.fir.kt index 2acdf445a48..df45601bc63 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWithBoundExtensionReceiver.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWithBoundExtensionReceiver.fir.kt @@ -10,6 +10,6 @@ fun A.foo() = "" class A { fun main() { - bar(::foo) checkType { _() } + bar(::foo) checkType { _() } } } diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguousWithVararg.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguousWithVararg.fir.kt deleted file mode 100644 index eb20864dd5e..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguousWithVararg.fir.kt +++ /dev/null @@ -1,16 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER - -fun fun1() {} -fun fun1(x: Int) {} - -val ref1 = ::fun1 - -fun fun2(vararg x: Int) {} -fun fun2(x: Int) {} - -val ref2 = ::fun2 - -fun fun3(x0: Int, vararg xs: Int) {} -fun fun3(x0: String, vararg xs: String) {} - -val ref3 = ::fun3 diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguousWithVararg.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguousWithVararg.kt index 4cb5391aaed..0c96700cd89 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguousWithVararg.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguousWithVararg.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER fun fun1() {} diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/byValType.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/byValType.fir.kt index 5c7a34df0f0..4618ff917eb 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/byValType.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/byValType.fir.kt @@ -3,7 +3,7 @@ fun foo() {} fun foo(s: String) {} -val x1 = ::foo +val x1 = ::foo val x2: () -> Unit = ::foo val x3: (String) -> Unit = ::foo val x4: (Int) -> Unit = ::foo diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/chooseCallableReferenceDependingOnInferredReceiver.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/chooseCallableReferenceDependingOnInferredReceiver.fir.kt index 7eea1faa468..0d4f9eb6956 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/chooseCallableReferenceDependingOnInferredReceiver.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/chooseCallableReferenceDependingOnInferredReceiver.fir.kt @@ -31,7 +31,7 @@ fun test() { val t3 = bar(::baz) t3 - bar(::foo) + bar(::foo) } } } diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/eagerAndPostponedCallableReferences.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/eagerAndPostponedCallableReferences.fir.kt index ef03a9f1c31..acea7de6160 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/eagerAndPostponedCallableReferences.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/eagerAndPostponedCallableReferences.fir.kt @@ -31,5 +31,5 @@ fun test() { val a6 = foo(::singleA, ::singleB) a6 - foo(::multiple, ::multiple) + foo(::multiple, ::multiple) } diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/moreSpecificAmbiguousExtensions.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/moreSpecificAmbiguousExtensions.fir.kt index a75b761ebc6..3b516fe4caf 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/moreSpecificAmbiguousExtensions.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/moreSpecificAmbiguousExtensions.fir.kt @@ -9,7 +9,7 @@ fun IB.extFun(x: IA) {} fun test() { val extFun1 = IA::extFun - val extFun2 = IB::extFun + val extFun2 = IB::extFun } fun testWithExpectedType() { @@ -17,5 +17,5 @@ fun testWithExpectedType() { val extFun_AA_B: IA.(IA) -> Unit = IB::extFun val extFun_BB_A: IB.(IB) -> Unit = IA::extFun val extFun_BA_B: IB.(IA) -> Unit = IB::extFun - val extFun_BB_B: IB.(IB) -> Unit = IB::extFun + val extFun_BB_B: IB.(IB) -> Unit = IB::extFun } diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/overloads.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/overloads.fir.kt deleted file mode 100644 index 45d92cebcae..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/overloads.fir.kt +++ /dev/null @@ -1,30 +0,0 @@ -// !CHECK_TYPE -// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION -import kotlin.reflect.KFunction1 - -open class A { - open fun bar() {} - - fun bas() {} -} -class B: A() { - override fun bar() {} - - fun bas(i: Int) {} -} - -fun A.foo() {} -fun B.foo() {} - -fun fas() {} -fun fas(i: Int = 1) {} - -fun test() { - B::foo // todo KT-9601 Chose maximally specific function in callable reference - - B::bar checkType { _>() } - - B::bas - - ::fas -} diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/overloads.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/overloads.kt index 79fadc1252c..86cf08ebaa4 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/overloads.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/overloads.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION import kotlin.reflect.KFunction1 diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/withAs.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/withAs.fir.kt deleted file mode 100644 index c2608845f67..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/withAs.fir.kt +++ /dev/null @@ -1,10 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER - -fun foo() {} -fun foo(s: String) {} - -fun bar(f: () -> Unit) = 1 -fun bar(f: (String) -> Unit) = 2 - -val x1 = ::foo as () -> Unit -val x2 = bar(::foo as (String) -> Unit) diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/withAs.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/withAs.kt index ff34f30b9ea..4de0a16ece9 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/withAs.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/withAs.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER fun foo() {} diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/withExtFun.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/withExtFun.fir.kt deleted file mode 100644 index a9800bade40..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/withExtFun.fir.kt +++ /dev/null @@ -1,27 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER, -EXTENSION_SHADOWED_BY_MEMBER - -import kotlin.reflect.* - -fun ofType(x: T): T = x - -class A { - val foo: Int = 0 - fun foo() {} - - fun bar() {} - val bar: Int = 0 -} - -fun A.foo(): String = "A" - -val x0 = A::foo - -val x1 = ofType<(A) -> Unit>(A::foo) -val x2 = ofType>(A::foo) -val x3: KProperty1 = A::foo -val x4: (A) -> String = A::foo - -val y0 = A::bar -val y1 = ofType<(A) -> Unit>(A::bar) -val y2 = ofType>(A::bar) -val y3: KProperty1 = A::bar diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/withExtFun.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/withExtFun.kt index cfe695bb2a9..6b2f4fde2e9 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/withExtFun.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/withExtFun.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -EXTENSION_SHADOWED_BY_MEMBER import kotlin.reflect.* diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/withPlaceholderTypes.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/withPlaceholderTypes.fir.kt index ae5c26750ad..58b19cde969 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/withPlaceholderTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/withPlaceholderTypes.fir.kt @@ -22,7 +22,7 @@ val x1 = fn1(1, ::foo, ::foo) val x2 = fn1(1, ::foo, ::bar) val x3 = fn2(::bar, ::foo) -val x4 = fn2(::foo, ::bar) -val x5 = fn2(::foo, ::foo) +val x4 = fn2(::foo, ::bar) +val x5 = fn2(::foo, ::foo) val x6 = fn3(1, ::qux) diff --git a/compiler/testData/diagnostics/tests/callableReference/unsupported/callableReferenceToLocalVariable.fir.kt b/compiler/testData/diagnostics/tests/callableReference/unsupported/callableReferenceToLocalVariable.fir.kt deleted file mode 100644 index 88f02aa36e6..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/unsupported/callableReferenceToLocalVariable.fir.kt +++ /dev/null @@ -1,8 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE - -fun a() { - val x = 10 - foo(::x) -} - -fun foo(a: Any) {} diff --git a/compiler/testData/diagnostics/tests/callableReference/unsupported/callableReferenceToLocalVariable.kt b/compiler/testData/diagnostics/tests/callableReference/unsupported/callableReferenceToLocalVariable.kt index 33a7235d2e5..6830eef3b8a 100644 --- a/compiler/testData/diagnostics/tests/callableReference/unsupported/callableReferenceToLocalVariable.kt +++ b/compiler/testData/diagnostics/tests/callableReference/unsupported/callableReferenceToLocalVariable.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE fun a() { diff --git a/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariable.fir.kt b/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariable.fir.kt deleted file mode 100644 index 48b11167566..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariable.fir.kt +++ /dev/null @@ -1,15 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE - -fun eat(value: Any) {} - -fun test(param: String) { - val a = ::param - - val local = "local" - val b = ::local - - val lambda = { -> } - val g = ::lambda - - eat(::param) -} diff --git a/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariable.kt b/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariable.kt index 3639382638e..9e8674acb1b 100644 --- a/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariable.kt +++ b/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariable.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE fun eat(value: Any) {} diff --git a/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariableWithSubstitution.fir.kt b/compiler/testData/diagnostics/tests/callableReference/unsupported/localVariableWithSubstitution.fir.kt index d6ed6422aac..19ec064942a 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 b32d30193bd..1b8fc15d6ba 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/callableReference/withQuestionMarks.fir.kt b/compiler/testData/diagnostics/tests/callableReference/withQuestionMarks.fir.kt index 75222ee926d..6c4a50f5d3e 100644 --- a/compiler/testData/diagnostics/tests/callableReference/withQuestionMarks.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/withQuestionMarks.fir.kt @@ -13,9 +13,9 @@ fun main() { val x7 = logger::info!!::print?::print val x8 = logger?::info!!::print?::print val x9 = logger!!::info?::print?::print - val x10 = logger::info?::print!!::print - val x11 = logger!!::info!!::print!!::print - val x12 = logger?::info!!::print!!::print + val x10 = logger::info?::print!!::print + val x11 = logger!!::info!!::print!!::print + val x12 = logger?::info!!::print!!::print val x13 = 42?::unresolved?::print val x14 = logger?!!::info?::print?::print diff --git a/compiler/testData/diagnostics/tests/cast/bare/AsNullableNotEnough.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/AsNullableNotEnough.fir.kt deleted file mode 100644 index b035f0012a6..00000000000 --- a/compiler/testData/diagnostics/tests/cast/bare/AsNullableNotEnough.fir.kt +++ /dev/null @@ -1,10 +0,0 @@ -// !CHECK_TYPE - -interface Tr -interface G - -fun test(tr: Tr) { - val v = tr as G? - // If v is not nullable, there will be a warning on this line: - checkSubtype>(v!!) -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/AsNullableNotEnough.kt b/compiler/testData/diagnostics/tests/cast/bare/AsNullableNotEnough.kt index ff5111e66af..22b627553c9 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/AsNullableNotEnough.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/AsNullableNotEnough.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !CHECK_TYPE interface Tr diff --git a/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullableNotEnough.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullableNotEnough.fir.kt deleted file mode 100644 index a4c197e79af..00000000000 --- a/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullableNotEnough.fir.kt +++ /dev/null @@ -1,9 +0,0 @@ -// !CHECK_TYPE - -interface Tr -interface G - -fun test(tr: Tr?) { - val v = tr as G? - checkSubtype>(v!!) -} diff --git a/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullableNotEnough.kt b/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullableNotEnough.kt index 01797878cb2..b2fc2d8729c 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullableNotEnough.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullableNotEnough.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !CHECK_TYPE interface Tr diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.fir.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.fir.kt index 2a95bc7574d..9bc610f707d 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.fir.kt @@ -24,7 +24,7 @@ fun Foo2.setX(y: T): T { fun Float.bar() {} fun test1() { - val fooSetRef = Foo<*>::setX + val fooSetRef = Foo<*>::setX val foo = Foo(1f) fooSetRef.invoke(foo, 1) @@ -42,7 +42,7 @@ fun test2() { } fun test3() { - val fooSetRef = Foo2<*>::setX + val fooSetRef = Foo2<*>::setX val foo = Foo2(1) fooSetRef.invoke(foo, "") diff --git a/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt b/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt index 9e37b8bf22d..e278af9d41b 100644 --- a/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/kt39220.fir.kt @@ -84,14 +84,14 @@ fun main() { bar1(::resolve) // OK // with LHS and conflicting projection - bar2(Foo::resolve) - bar2(Foo::resolve) - bar2(Foo::resolve) + bar2(Foo::resolve) + bar2(Foo::resolve) + bar2(Foo::resolve) // with LHS and Any? expected type - bar3(Foo::resolve) - bar3(Foo::resolve) - bar3(Foo::resolve) + bar3(Foo::resolve) + bar3(Foo::resolve) + bar3(Foo::resolve) // with LHS and `Function` expected type bar4(Foo::resolve) // ERROR before the fix in NI diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt32862_both.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt32862_both.fir.kt index d887e36ef47..452faa4aede 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt32862_both.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt32862_both.fir.kt @@ -12,5 +12,5 @@ fun G.foo(vararg values: V2) = build() fun forReference(ref: Any?) {} fun test() { - forReference(G::foo) + forReference(G::foo) } diff --git a/compiler/testData/diagnostics/tests/inference/reportingImprovements/kt42620.fir.kt b/compiler/testData/diagnostics/tests/inference/reportingImprovements/kt42620.fir.kt index 7b78f02cca0..b2a7f40c324 100644 --- a/compiler/testData/diagnostics/tests/inference/reportingImprovements/kt42620.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/reportingImprovements/kt42620.fir.kt @@ -6,10 +6,10 @@ fun main1() = when { else -> Foo::plus } -fun main2() = if (true) Foo::minus else Foo::times +fun main2() = if (true) Foo::minus else Foo::times -fun main3() = if (true) { Foo::minus } else { Foo::times } +fun main3() = if (true) { Foo::minus } else { Foo::times } -fun main4() = try { Foo::minus } finally { Foo::times } +fun main4() = try { Foo::minus } finally { Foo::times } -fun main5() = Foo::minus ?: Foo::times +fun main5() = Foo::minus ?: Foo::times diff --git a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt index bc3a4c9cf4c..5fb1242f4b3 100644 --- a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt @@ -29,13 +29,13 @@ fun poll11(flag: Boolean) { } fun poll12(flag: Boolean) { - val inv = if (flag) { ::bar3 } else { ::foo3 } + val inv = if (flag) { ::bar3 } else { ::foo3 } inv() } fun poll13(flag: Boolean) { - val inv = if (flag) { ::bar2 } else { ::foo3 } - inv() + val inv = if (flag) { ::bar2 } else { ::foo3 } + inv() } fun poll14(flag: Boolean) { @@ -44,7 +44,7 @@ fun poll14(flag: Boolean) { } fun poll15(flag: Boolean) { - val inv = if (flag) { ::bar5 } else { ::foo5 } + val inv = if (flag) { ::bar5 } else { ::foo5 } inv() } @@ -59,7 +59,7 @@ fun poll17(flag: Boolean) { } fun poll2(flag: Boolean) { - val inv = when (flag) { true -> ::bar else -> ::foo } + val inv = when (flag) { true -> ::bar else -> ::foo } inv() } @@ -69,7 +69,7 @@ fun poll21(flag: Boolean) { } fun poll22(flag: Boolean) { - val inv = when (flag) { true -> ::bar3 else -> ::foo3 } + val inv = when (flag) { true -> ::bar3 else -> ::foo3 } inv() } @@ -79,7 +79,7 @@ fun poll23(flag: Boolean) { } fun poll24(flag: Boolean) { - val inv = when (flag) { true -> ::bar5 else -> ::foo5 } + val inv = when (flag) { true -> ::bar5 else -> ::foo5 } inv } @@ -94,7 +94,7 @@ fun poll26(flag: Boolean) { } fun poll3(flag: Boolean) { - val inv = when (flag) { true -> ::bar false -> ::foo } + val inv = when (flag) { true -> ::bar false -> ::foo } inv() } @@ -104,7 +104,7 @@ fun poll31(flag: Boolean) { } fun poll32(flag: Boolean) { - val inv = when (flag) { true -> ::bar3 false -> ::foo3 } + val inv = when (flag) { true -> ::bar3 false -> ::foo3 } inv() } @@ -114,7 +114,7 @@ fun poll33(flag: Boolean) { } fun poll34(flag: Boolean) { - val inv = when (flag) { true -> ::bar5 false -> ::foo5 } + val inv = when (flag) { true -> ::bar5 false -> ::foo5 } inv } @@ -129,7 +129,7 @@ fun poll36(flag: Boolean) { } fun poll4() { - val inv = try { ::bar } finally { ::foo } + val inv = try { ::bar } finally { ::foo } inv() } @@ -139,7 +139,7 @@ fun poll41() { } fun poll42() { - val inv = try { ::bar3 } finally { ::foo3 } + val inv = try { ::bar3 } finally { ::foo3 } inv() } @@ -149,7 +149,7 @@ fun poll43() { } fun poll44() { - val inv = try { ::bar5 } finally { ::foo5 } + val inv = try { ::bar5 } finally { ::foo5 } inv() } @@ -164,7 +164,7 @@ fun poll46() { } fun poll5() { - val inv = try { ::bar } catch (e: Exception) { ::foo } finally { ::foo } + val inv = try { ::bar } catch (e: Exception) { ::foo } finally { ::foo } inv() } @@ -174,7 +174,7 @@ fun poll51() { } fun poll52() { - val inv = try { ::bar3 } catch (e: Exception) { ::foo3 } finally { ::foo3 } + val inv = try { ::bar3 } catch (e: Exception) { ::foo3 } finally { ::foo3 } inv() } @@ -184,7 +184,7 @@ fun poll53() { } fun poll54() { - val inv = try { ::bar5 } catch (e: Exception) { ::foo5 } finally { ::foo5 } + val inv = try { ::bar5 } catch (e: Exception) { ::foo5 } finally { ::foo5 } inv() } @@ -234,7 +234,7 @@ fun poll66() { } fun poll7() { - val inv = ::bar!! + val inv = ::bar!! inv() } @@ -244,7 +244,7 @@ fun poll71() { } fun poll72() { - val inv = ::bar3!! + val inv = ::bar3!! inv() } @@ -254,7 +254,7 @@ fun poll73() { } fun poll74() { - val inv = ::bar5!! + val inv = ::bar5!! inv } diff --git a/compiler/testData/diagnostics/tests/j+k/properties/fieldPropertyOverloadsDisabled.fir.kt b/compiler/testData/diagnostics/tests/j+k/properties/fieldPropertyOverloadsDisabled.fir.kt index 6e6e7cf4c55..f5979eeaf51 100644 --- a/compiler/testData/diagnostics/tests/j+k/properties/fieldPropertyOverloadsDisabled.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/properties/fieldPropertyOverloadsDisabled.fir.kt @@ -23,6 +23,6 @@ fun main(c: CollectionWithSize) { CompressionType.ZIP.name checkType { _() } c.size checkType { _() } - CompressionType.ZIP::name checkType { _>() } - c::size checkType { _>() } + CompressionType.ZIP::name checkType { _>() } + c::size checkType { _>() } } diff --git a/compiler/testData/diagnostics/tests/resolve/callableReferenceInCST.fir.kt b/compiler/testData/diagnostics/tests/resolve/callableReferenceInCST.fir.kt index 5ce865ec935..6152c6d22c4 100644 --- a/compiler/testData/diagnostics/tests/resolve/callableReferenceInCST.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/callableReferenceInCST.fir.kt @@ -4,33 +4,33 @@ fun testWhen(x: Any?) { val y = when (x) { null -> "" - else -> ::unresolved + else -> ::unresolved } } fun testWhenWithBraces(x: Any?) { val z = when(x) { null -> { "" } - else -> { ::unresolved } + else -> { ::unresolved } } } fun testIf(x: Any?) { - val y = if (x != null) ::unresolved else null + val y = if (x != null) ::unresolved else null } fun testIfWithBraces(x: Any?) { - val z = if (x != null) { ::unresolved } else { null } + val z = if (x != null) { ::unresolved } else { null } } fun testElvis(x: Any?) { - val y = x ?: ::unresolved + val y = x ?: ::unresolved } fun testExclExcl() { - val y = :: unresolved!! + val y = :: unresolved!! } fun testTry() { - val v = try { ::unresolved } catch (e: Exception) {} + val v = try { ::unresolved } catch (e: Exception) {} } diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/completion/postponedArgumentsAnalysis/callableReferences.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/completion/postponedArgumentsAnalysis/callableReferences.fir.kt index 7a1581ae9dd..eb4ce154e70 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/completion/postponedArgumentsAnalysis/callableReferences.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/completion/postponedArgumentsAnalysis/callableReferences.fir.kt @@ -49,7 +49,7 @@ fun main() { select(id(")!>::foo4), id { x: A -> }, id { it }) select(id(")!>::foo4), id { x: B -> }, id { it }) // Expected ambiguity - select(id(::foo4), id { x: A -> }, id { x: B -> }, id { it }) + select(id(::foo4), id { x: A -> }, id { x: B -> }, id { it }) select(id(::foo5), id { x: A -> }, id { x: B -> }, id { it }) diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/kt42620.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/kt42620.fir.kt index 7b78f02cca0..b2a7f40c324 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/kt42620.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/kt42620.fir.kt @@ -6,10 +6,10 @@ fun main1() = when { else -> Foo::plus } -fun main2() = if (true) Foo::minus else Foo::times +fun main2() = if (true) Foo::minus else Foo::times -fun main3() = if (true) { Foo::minus } else { Foo::times } +fun main3() = if (true) { Foo::minus } else { Foo::times } -fun main4() = try { Foo::minus } finally { Foo::times } +fun main4() = try { Foo::minus } finally { Foo::times } -fun main5() = Foo::minus ?: Foo::times +fun main5() = Foo::minus ?: Foo::times 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 01af27251fe..58efe42ad22 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 @@ -11,7 +11,7 @@ class Case1() { } fun case() { - Companion(::x) + Companion(::x) } val x = "" @@ -27,7 +27,7 @@ class Case2() { } fun case() { - Companion(::x) + Companion(::x) } val x = C() @@ -54,8 +54,8 @@ class Case3() : I { fun x() = "" as CharSequence fun case() { - I.invoke(::x) - I(::x) - Case3(::x) + I.invoke(::x) + I(::x) + Case3(::x) } } diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.2.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.2.fir.kt index e86b50ac5f0..149cd4d796c 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.2.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.2.fir.kt @@ -11,7 +11,7 @@ import libCase1.* import kotlin.text.format fun case1() { - val y1 =(String)::format + val y1 =(String)::format } // FILE: LibCase1.kt @@ -28,7 +28,7 @@ import libCase2.* import kotlin.text.* fun case2() { - val y1 =(String)::format + val y1 =(String)::format } // FILE: LibCase2.kt diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.3.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.3.fir.kt index bf8698d6627..ce61061202f 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.3.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.3.fir.kt @@ -10,7 +10,7 @@ package testsCase1 import libCase1.* fun case1() { - val y1 =(A)::boo + val y1 =(A)::boo } // FILE: LibCase1.kt @@ -31,7 +31,7 @@ import libCase2.A import libCase2.boo fun case2() { - val y1 =(A)::boo + val y1 =(A)::boo } // FILE: LibCase2.kt diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.4.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.4.fir.kt index 1b144653f61..3a4faff3dd6 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.4.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.4.fir.kt @@ -11,7 +11,7 @@ package testsCase1 import libCase1.boo fun case1() { - val y1 =1::boo + val y1 =1::boo } // FILE: LibCase1.kt @@ -27,7 +27,7 @@ package testsCase2 import libCase2.* fun case2() { - val y1 =1::boo + val y1 =1::boo } // FILE: LibCase2.kt diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.5.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.5.fir.kt index 09d5eaf1ab5..7ab08f6ddca 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.5.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/neg/1.5.fir.kt @@ -11,7 +11,7 @@ package testsCase1 import libCase1.boo fun case1() { - val y1 =::boo + val y1 =::boo } // FILE: LibCase1.kt @@ -27,7 +27,7 @@ package testsCase2 import libCase2.* fun case2() { - val y1 =::boo + val y1 =::boo } val boo: String @@ -46,7 +46,7 @@ package testsCase3 import libCase3.* fun case3() { - val y1 =::boo + val y1 =::boo } val boo: String diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt index c1fd73da009..0c74591b5f3 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt @@ -180,7 +180,7 @@ fun case_12(x: TypealiasNullableStringIndirect, y: TypealiasNullableStringIndire // TESTCASE NUMBER: 13 fun case_13(x: otherpackage.Case13?) = - if ((x == null !is Boolean) !== true) { + if ((x == null !is Boolean) !== true) { throw Exception() } else { x