From cbbbf40b904e96ac4e9d41d501dbac04cb04a568 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Wed, 19 Feb 2020 17:35:10 +0300 Subject: [PATCH] [NI] Fix isSuccessful property for member with LowPriority resolution The problem was introduced in e40ba73950d3bd83ae0baa02eeb8781d161a4f80 --- ...endDiagnosticsTestWithStdlibGenerated.java | 5 ++++ .../kotlin/resolve/calls/tower/TowerUtils.kt | 2 +- ...ckLowPriorityIsResolvedSuccessfully.fir.kt | 15 +++++++++++ .../checkLowPriorityIsResolvedSuccessfully.kt | 15 +++++++++++ ...checkLowPriorityIsResolvedSuccessfully.txt | 27 +++++++++++++++++++ .../DiagnosticsTestWithStdLibGenerated.java | 5 ++++ ...ticsTestWithStdLibUsingJavacGenerated.java | 5 ++++ 7 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.fir.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.txt diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java index 96e1f1ac8df..ba62289ffd5 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java @@ -1908,6 +1908,11 @@ public class FirOldFrontendDiagnosticsTestWithStdlibGenerated extends AbstractFi KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @TestMetadata("checkLowPriorityIsResolvedSuccessfully.kt") + public void testCheckLowPriorityIsResolvedSuccessfully() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.kt"); + } + @TestMetadata("exactAnnotation.kt") public void testExactAnnotation() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.kt"); diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerUtils.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerUtils.kt index 173282abadc..4b9bf9d0a14 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerUtils.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerUtils.kt @@ -27,7 +27,7 @@ private val INAPPLICABLE_STATUSES = setOf( ) val ResolutionCandidateApplicability.isSuccess: Boolean - get() = this <= ResolutionCandidateApplicability.RESOLVED_WITH_ERROR + get() = this <= ResolutionCandidateApplicability.RESOLVED_LOW_PRIORITY val CallableDescriptor.isSynthesized: Boolean get() = (this is CallableMemberDescriptor && kind == CallableMemberDescriptor.Kind.SYNTHESIZED) diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.fir.kt new file mode 100644 index 00000000000..8447667a390 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.fir.kt @@ -0,0 +1,15 @@ +class Foo { + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + @kotlin.internal.LowPriorityInOverloadResolution + val test: Bar = Bar() +} + +fun Foo.test() {} +class Bar +class Scope { + operator fun Bar.invoke(f: () -> Unit) {} +} + +fun Scope.bar(e: Foo) { + e.test {} +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.kt new file mode 100644 index 00000000000..bb20695bd26 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.kt @@ -0,0 +1,15 @@ +class Foo { + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + @kotlin.internal.LowPriorityInOverloadResolution + val test: Bar = Bar() +} + +fun Foo.test() {} +class Bar +class Scope { + operator fun Bar.invoke(f: () -> Unit) {} +} + +fun Scope.bar(e: Foo) { + e.test {} +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.txt new file mode 100644 index 00000000000..6821e31e831 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.txt @@ -0,0 +1,27 @@ +package + +public fun Scope.bar(/*0*/ e: Foo): kotlin.Unit +public fun Foo.test(): kotlin.Unit + +public final class Bar { + public constructor Bar() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class Foo { + public constructor Foo() + @kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) @kotlin.internal.LowPriorityInOverloadResolution public final val test: Bar + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class Scope { + public constructor Scope() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + public final operator fun Bar.invoke(/*0*/ f: () -> kotlin.Unit): kotlin.Unit +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index c37500a8003..950135d3129 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -2858,6 +2858,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @TestMetadata("checkLowPriorityIsResolvedSuccessfully.kt") + public void testCheckLowPriorityIsResolvedSuccessfully() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.kt"); + } + @TestMetadata("exactAnnotation.kt") public void testExactAnnotation() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index dbd2113fa58..cc4342d157a 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -2858,6 +2858,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @TestMetadata("checkLowPriorityIsResolvedSuccessfully.kt") + public void testCheckLowPriorityIsResolvedSuccessfully() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.kt"); + } + @TestMetadata("exactAnnotation.kt") public void testExactAnnotation() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.kt");