diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt index 62e7e499b3c..bd5eeb944cd 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.fir.expressions.FirErrorResolvedQualifier import org.jetbrains.kotlin.fir.references.FirErrorNamedReference import org.jetbrains.kotlin.fir.resolve.diagnostics.* import org.jetbrains.kotlin.fir.types.FirErrorTypeRef -import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability +import org.jetbrains.kotlin.resolve.calls.tower.isSuccess import org.jetbrains.kotlin.utils.addToStdlib.safeAs class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollector) : AbstractDiagnosticCollectorComponent(collector) { @@ -65,7 +65,7 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect is ConeUnresolvedNameError -> FirErrors.UNRESOLVED_REFERENCE.on(source, diagnostic.name.asString()) is ConeHiddenCandidateError -> FirErrors.HIDDEN.on(source, diagnostic.candidateSymbol) is ConeInapplicableCandidateError -> FirErrors.INAPPLICABLE_CANDIDATE.on(source, diagnostic.candidateSymbol) - is ConeAmbiguityError -> if (diagnostic.applicability < CandidateApplicability.SYNTHETIC_RESOLVED) { + is ConeAmbiguityError -> if (!diagnostic.applicability.isSuccess) { FirErrors.NONE_APPLICABLE.on(source, diagnostic.candidates) } else { FirErrors.AMBIGUITY.on(source, diagnostic.candidates) 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 8b92af61a38..b947ccb9e5c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -37,6 +37,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability +import org.jetbrains.kotlin.resolve.calls.tower.isSuccess import org.jetbrains.kotlin.types.Variance class FirCallResolver( @@ -149,7 +150,7 @@ class FirCallResolver( info, ) val bestCandidates = result.bestCandidates() - val reducedCandidates = if (result.currentApplicability < CandidateApplicability.SYNTHETIC_RESOLVED) { + val reducedCandidates = if (!result.currentApplicability.isSuccess) { bestCandidates.toSet() } else { val onSuperReference = (explicitReceiver as? FirQualifiedAccessExpression)?.calleeReference is FirSuperReference @@ -157,7 +158,7 @@ class FirCallResolver( bestCandidates, discriminateGenerics = true, discriminateAbstracts = onSuperReference ) } - if ((reducedCandidates.isEmpty() || result.currentApplicability < CandidateApplicability.SYNTHETIC_RESOLVED) && + if ((reducedCandidates.isEmpty() || !result.currentApplicability.isSuccess) && explicitReceiver?.typeRef?.coneTypeSafe() != null ) { val approximatedQualifiedAccess = qualifiedAccess.transformExplicitReceiver(integerLiteralTypeApproximator, null) @@ -192,8 +193,7 @@ class FirCallResolver( ) if (qualifiedAccess.explicitReceiver == null) { - if (result.applicability < CandidateApplicability.SYNTHETIC_RESOLVED - ) { + if (!result.applicability.isSuccess) { // We should run QualifierResolver if no successful candidates are available // Otherwise expression (even ambiguous) beat qualifier qualifiedResolver.tryResolveAsQualifier(qualifiedAccess.source)?.let { resolvedQualifier -> @@ -260,7 +260,7 @@ class FirCallResolver( manager = TowerResolveManager(localCollector), ) val bestCandidates = result.bestCandidates() - val noSuccessfulCandidates = result.currentApplicability < CandidateApplicability.SYNTHETIC_RESOLVED + val noSuccessfulCandidates = !result.currentApplicability.isSuccess val reducedCandidates = if (noSuccessfulCandidates) { bestCandidates.toSet() } else { @@ -419,7 +419,7 @@ class FirCallResolver( call: FirDelegatedConstructorCall, name: Name, result: CandidateCollector, callInfo: CallInfo ): FirDelegatedConstructorCall { val bestCandidates = result.bestCandidates() - val reducedCandidates = if (result.currentApplicability < CandidateApplicability.SYNTHETIC_RESOLVED) { + val reducedCandidates = if (!result.currentApplicability.isSuccess) { bestCandidates.toSet() } else { conflictResolver.chooseMaximallySpecificCandidates(bestCandidates, discriminateGenerics = true) @@ -498,7 +498,7 @@ class FirCallResolver( name ) - applicability < CandidateApplicability.SYNTHETIC_RESOLVED -> { + !applicability.isSuccess -> { val candidate = candidates.single() val diagnostic = when (applicability) { CandidateApplicability.HIDDEN -> ConeHiddenCandidateError(candidate.symbol) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateCollector.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateCollector.kt index 9860ecd70b1..45e251b875e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateCollector.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateCollector.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents import org.jetbrains.kotlin.fir.resolve.calls.tower.TowerGroup import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability +import org.jetbrains.kotlin.resolve.calls.tower.isSuccess open class CandidateCollector( val components: BodyResolveComponents, @@ -50,7 +51,7 @@ open class CandidateCollector( isSuccess() && bestGroup < group fun isSuccess(): Boolean { - return currentApplicability >= CandidateApplicability.SYNTHETIC_RESOLVED + return currentApplicability.isSuccess } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CheckerSink.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CheckerSink.kt index e0bc198c22b..c18effb46f6 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CheckerSink.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CheckerSink.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.fir.PrivateForInline import org.jetbrains.kotlin.fir.resolve.inference.InferenceComponents import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability +import org.jetbrains.kotlin.resolve.calls.tower.isSuccess import kotlin.coroutines.Continuation abstract class CheckerSink { @@ -52,6 +53,6 @@ class CheckerSinkImpl( } override val needYielding: Boolean - get() = stopOnFirstError && current < CandidateApplicability.SYNTHETIC_RESOLVED + get() = stopOnFirstError && !current.isSuccess } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStageRunner.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStageRunner.kt index 9985a182ea0..42929bf2477 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStageRunner.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStageRunner.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.fir.resolve.inference.InferenceComponents import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability +import org.jetbrains.kotlin.resolve.calls.tower.isSuccess import kotlin.coroutines.Continuation import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext @@ -35,7 +36,7 @@ class ResolutionStageRunner(val components: InferenceComponents) { while (!finished) { sink.continuation!!.resume(Unit) - if (sink.current < CandidateApplicability.SYNTHETIC_RESOLVED) { + if (!sink.current.isSuccess) { break } } 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 7b44c2abfa0..116205b44f8 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 @@ -21,6 +21,7 @@ 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,7 +79,7 @@ class PostponedArgumentsAnalyzer( ?: Pair(null, CandidateApplicability.INAPPLICABLE) val namedReference = when { - resultingCandidate == null || applicability < CandidateApplicability.SYNTHETIC_RESOLVED -> + resultingCandidate == null || !applicability.isSuccess -> buildErrorNamedReference { source = callableReferenceAccess.source diagnostic = ConeUnresolvedReferenceError(callableReferenceAccess.calleeReference.name) diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/resolver/SingleCandidateResolver.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/resolver/SingleCandidateResolver.kt index fe00a34bc98..4e222f47afc 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/resolver/SingleCandidateResolver.kt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/resolver/SingleCandidateResolver.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirBodyResolve import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability +import org.jetbrains.kotlin.resolve.calls.tower.isSuccess class SingleCandidateResolver( private val firSession: FirSession, @@ -70,7 +70,7 @@ class SingleCandidateResolver( ) val applicability = resolutionStageRunner.processCandidate(candidate, stopOnFirstError = true) - if (applicability >= CandidateApplicability.SYNTHETIC_RESOLVED) { + if (applicability.isSuccess) { return completeResolvedCandidate(candidate, resolutionParameters) } return null