From 41cc926953727cb133f6b8d7149436c345329afe Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 7 Feb 2024 15:51:10 +0100 Subject: [PATCH] Minor. Reorder some methods in FirInferenceSession Put them in the order in which they are assumed to be called --- .../FirDelegatedPropertyInferenceSession.kt | 10 ++--- .../resolve/inference/FirInferenceSession.kt | 42 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirDelegatedPropertyInferenceSession.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirDelegatedPropertyInferenceSession.kt index 5e5929c2330..0756e2bf558 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirDelegatedPropertyInferenceSession.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirDelegatedPropertyInferenceSession.kt @@ -58,6 +58,11 @@ class FirDelegatedPropertyInferenceSession( private var wasCompletionRun = false + override fun baseConstraintStorageForCandidate(candidate: Candidate): ConstraintStorage? { + if (wasCompletionRun || !candidate.callInfo.callSite.isAnyOfDelegateOperators()) return null + return currentConstraintStorage + } + override fun customCompletionModeInsteadOfFull(call: FirResolvable): ConstraintSystemCompletionMode? = when { call.isAnyOfDelegateOperators() && !wasCompletionRun -> ConstraintSystemCompletionMode.PARTIAL else -> null @@ -93,11 +98,6 @@ class FirDelegatedPropertyInferenceSession( private fun T.isProvideDelegate() where T : FirResolvable, T : FirStatement = isAnyOfDelegateOperators() && (this as FirResolvable).candidate()?.callInfo?.name == OperatorNameConventions.PROVIDE_DELEGATE - override fun baseConstraintStorageForCandidate(candidate: Candidate): ConstraintStorage? { - if (wasCompletionRun || !candidate.callInfo.callSite.isAnyOfDelegateOperators()) return null - return currentConstraintStorage - } - fun completeSessionOrPostponeIfNonRoot(onCompletionResultsWriting: (ConeSubstitutor) -> Unit) { check(!wasCompletionRun) wasCompletionRun = true diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirInferenceSession.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirInferenceSession.kt index ba2ba83d0f3..d44d9772640 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirInferenceSession.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirInferenceSession.kt @@ -16,6 +16,27 @@ import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage import org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImpl abstract class FirInferenceSession { + open fun baseConstraintStorageForCandidate(candidate: Candidate): ConstraintStorage? = null + + open fun customCompletionModeInsteadOfFull( + call: FirResolvable, + ): ConstraintSystemCompletionMode? = null + + abstract fun processPartiallyResolvedCall( + call: T, + resolutionMode: ResolutionMode, + completionMode: ConstraintSystemCompletionMode + ) where T : FirResolvable, T : FirStatement + + open fun runLambdaCompletion(candidate: Candidate, forOverloadByLambdaReturnType: Boolean, block: () -> Unit): ConstraintStorage? { + block() + return null + } + + open fun runCallableReferenceResolution(candidate: Candidate, block: () -> T): T = block() + + open fun addSubtypeConstraintIfCompatible(lowerType: ConeKotlinType, upperType: ConeKotlinType, element: FirElement) {} + companion object { val DEFAULT: FirInferenceSession = object : FirInferenceSession() { override fun processPartiallyResolvedCall( @@ -37,25 +58,4 @@ abstract class FirInferenceSession { } } } - - open fun runLambdaCompletion(candidate: Candidate, forOverloadByLambdaReturnType: Boolean, block: () -> Unit): ConstraintStorage? { - block() - return null - } - - open fun runCallableReferenceResolution(candidate: Candidate, block: () -> T): T = block() - - open fun customCompletionModeInsteadOfFull( - call: FirResolvable, - ): ConstraintSystemCompletionMode? = null - - abstract fun processPartiallyResolvedCall( - call: T, - resolutionMode: ResolutionMode, - completionMode: ConstraintSystemCompletionMode - ) where T : FirResolvable, T : FirStatement - - open fun baseConstraintStorageForCandidate(candidate: Candidate): ConstraintStorage? = null - - open fun addSubtypeConstraintIfCompatible(lowerType: ConeKotlinType, upperType: ConeKotlinType, element: FirElement) {} }