~ drop outerConstraintStorage
diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt
index c1f2c9f..5b8384f 100644
--- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt
+++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt
@@ -352,9 +352,7 @@
if (pclaInferenceSession != null) {
transformer.context.withInferenceSession(pclaInferenceSession) {
- transformer.context.withOuterConstraintStorage(candidate.system.currentStorage()) {
- lambdaArgument.transformSingle(transformer, ResolutionMode.LambdaResolution(expectedReturnTypeRef))
- }
+ lambdaArgument.transformSingle(transformer, ResolutionMode.LambdaResolution(expectedReturnTypeRef))
applyResultsToMainCandidate()
}
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 2d75766..b71e994 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,18 +58,6 @@
private var wasCompletionRun = false
- // TODO after PCLA (KT-59107):
- // Outer system seems to be a property of a concrete call resolution and probably should be applied to concrete call resolution
- override fun <R> onCandidatesResolution(call: FirFunctionCall, candidatesResolutionCallback: () -> R): R {
- if (wasCompletionRun || !call.isAnyOfDelegateOperators()) return candidatesResolutionCallback()
- requireCallIsDelegateOperator(call)
-
- return resolutionContext.bodyResolveContext.withOuterConstraintStorage(
- currentConstraintSystem.currentStorage(),
- candidatesResolutionCallback
- )
- }
-
override fun customCompletionModeInsteadOfFull(call: FirResolvable): ConstraintSystemCompletionMode? = when {
call.isAnyOfDelegateOperators() && !wasCompletionRun -> ConstraintSystemCompletionMode.PARTIAL
else -> null
@@ -105,8 +93,10 @@
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? =
- resolutionContext.bodyResolveContext.outerConstraintStorage.takeIf { it !== ConstraintStorage.Empty }
+ override fun baseConstraintStorageForCandidate(candidate: Candidate): ConstraintStorage? {
+ if (wasCompletionRun || !candidate.callInfo.callSite.isAnyOfDelegateOperators()) return null
+ return currentConstraintStorage
+ }
fun completeSessionOrPostponeIfNonRoot(onCompletionResultsWriting: (ConeSubstitutor) -> Unit) {
check(!wasCompletionRun)
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 fb32c71..ba2ba83 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
@@ -6,7 +6,6 @@
package org.jetbrains.kotlin.fir.resolve.inference
import org.jetbrains.kotlin.fir.FirElement
-import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
import org.jetbrains.kotlin.fir.expressions.FirResolvable
import org.jetbrains.kotlin.fir.expressions.FirStatement
import org.jetbrains.kotlin.fir.resolve.ResolutionMode
@@ -56,8 +55,6 @@
completionMode: ConstraintSystemCompletionMode
) where T : FirResolvable, T : FirStatement
- open fun <R> onCandidatesResolution(call: FirFunctionCall, candidatesResolutionCallback: () -> R) = candidatesResolutionCallback()
-
open fun baseConstraintStorageForCandidate(candidate: Candidate): ConstraintStorage? = null
open fun addSubtypeConstraintIfCompatible(lowerType: ConeKotlinType, upperType: ConeKotlinType, element: FirElement) {}
diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt
index d6a5953..662f7d3 100644
--- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt
+++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt
@@ -37,7 +37,6 @@
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames.UNDERSCORE_FOR_UNUSED_VAR
-import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
import org.jetbrains.kotlin.util.PrivateForInline
class BodyResolveContext(
@@ -106,16 +105,6 @@
}
}
- /**
- * CS for an outer type system if it's relevant, for example, in the case of `val x by myGenericDelegateCall()`,
- * relevant `getValue` call is expected to be resolved in the context of an outer CS built from `myGenericDelegateCall()` and
- * probably using its type variables inside `getValue` candidates resolution.
- *
- * Note that it's not assumed to modify the storage, but only use it as a base system content for the candidate.
- */
- @set:PrivateForInline
- var outerConstraintStorage: ConstraintStorage = ConstraintStorage.Empty
-
val anonymousFunctionsAnalyzedInDependentContext: MutableSet<FirFunctionSymbol<*>> = mutableSetOf()
var containingClassDeclarations: ArrayDeque<FirRegularClass> = ArrayDeque()
@@ -389,8 +378,6 @@
if (this@BodyResolveContext.inferenceSession is FirPCLAInferenceSession) {
inferenceSession = this@BodyResolveContext.inferenceSession
}
-
- outerConstraintStorage = this@BodyResolveContext.outerConstraintStorage
}
// withElement PUBLIC API
@@ -876,21 +863,6 @@
}
@OptIn(PrivateForInline::class)
- inline fun <T> withOuterConstraintStorage(
- storage: ConstraintStorage,
- f: () -> T
- ): T {
- val oldStorage = this.outerConstraintStorage
- this.outerConstraintStorage = storage
- return try {
- f()
- } finally {
- this.outerConstraintStorage = oldStorage
- }
- }
-
-
- @OptIn(PrivateForInline::class)
inline fun <T> withConstructor(constructor: FirConstructor, f: () -> T): T =
withContainer(constructor, f)
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 a284fc5..4c49bda 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
@@ -437,9 +437,7 @@
functionCall
}
- val resultExpression = context.inferenceSession.onCandidatesResolution(withTransformedArguments) {
- callResolver.resolveCallAndSelectCandidate(withTransformedArguments, data)
- }
+ val resultExpression = callResolver.resolveCallAndSelectCandidate(withTransformedArguments, data)
val completeInference = callCompleter.completeCall(resultExpression, data)
val result = completeInference.transformToIntegerOperatorCallOrApproximateItIfNeeded(data)
@@ -1746,4 +1744,4 @@
this.source = newSource
this.resolvedSymbol = oldCalleeReference.resolvedSymbol
})
-}
\ No newline at end of file
+}