Minor. Reorder some methods in FirInferenceSession

Put them in the order in which they are assumed to be called
This commit is contained in:
Denis.Zharkov
2024-02-07 15:51:10 +01:00
committed by Space Team
parent b86c0d990e
commit 41cc926953
2 changed files with 26 additions and 26 deletions
@@ -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> 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
@@ -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 <T> 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 <T> 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 <T> processPartiallyResolvedCall(
@@ -37,25 +58,4 @@ abstract class FirInferenceSession {
}
}
}
open fun runLambdaCompletion(candidate: Candidate, forOverloadByLambdaReturnType: Boolean, block: () -> Unit): ConstraintStorage? {
block()
return null
}
open fun <T> runCallableReferenceResolution(candidate: Candidate, block: () -> T): T = block()
open fun customCompletionModeInsteadOfFull(
call: FirResolvable,
): ConstraintSystemCompletionMode? = null
abstract fun <T> 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) {}
}