[FE 1.0] Store constraint system in call resolution result instead of constraint storage
This commit is contained in:
committed by
teamcity
parent
cedd98148c
commit
74f294d849
+6
-3
@@ -438,10 +438,12 @@ class BuilderInferenceSession(
|
||||
integrateConstraints(initialStorage, nonFixedToVariablesSubstitutor, false)
|
||||
|
||||
for (call in commonCalls) {
|
||||
integrateConstraints(call.callResolutionResult.constraintSystem, nonFixedToVariablesSubstitutor, false)
|
||||
val storage = call.callResolutionResult.constraintSystem.getBuilder().currentStorage()
|
||||
integrateConstraints(storage, nonFixedToVariablesSubstitutor, false)
|
||||
}
|
||||
for (call in partiallyResolvedCallsInfo) {
|
||||
integrateConstraints(call.callResolutionResult.constraintSystem, nonFixedToVariablesSubstitutor, true)
|
||||
val storage = call.callResolutionResult.constraintSystem.getBuilder().currentStorage()
|
||||
integrateConstraints(storage, nonFixedToVariablesSubstitutor, true)
|
||||
}
|
||||
|
||||
return commonSystem.notFixedTypeVariables.all { it.value.constraints.isEmpty() }
|
||||
@@ -469,7 +471,8 @@ class BuilderInferenceSession(
|
||||
nonFixedTypesToResultSubstitutor: NewTypeSubstitutor,
|
||||
nonFixedTypesToResult: Map<TypeConstructor, UnwrappedType>
|
||||
) {
|
||||
val resultingCallSubstitutor = completedCall.callResolutionResult.constraintSystem.fixedTypeVariables.entries
|
||||
val storage = completedCall.callResolutionResult.constraintSystem.getBuilder().currentStorage()
|
||||
val resultingCallSubstitutor = storage.fixedTypeVariables.entries
|
||||
.associate { it.key to nonFixedTypesToResultSubstitutor.safeSubstitute(it.value as UnwrappedType) } // TODO: SUB
|
||||
|
||||
val resultingSubstitutor =
|
||||
|
||||
+3
@@ -103,6 +103,9 @@ class KotlinResolutionCallbacksImpl(
|
||||
) as KotlinType
|
||||
}
|
||||
|
||||
override fun createEmptyConstraintSystem(): NewConstraintSystem =
|
||||
NewConstraintSystemImpl(callComponents.constraintInjector, callComponents.builtIns, callComponents.kotlinTypeRefiner)
|
||||
|
||||
override fun resolveCallableReferenceArgument(
|
||||
argument: CallableReferenceKotlinCallArgument,
|
||||
expectedType: UnwrappedType?,
|
||||
|
||||
+2
-1
@@ -107,7 +107,8 @@ class KotlinToResolvedCallTransformer(
|
||||
is CompletedCallResolutionResult, is ErrorCallResolutionResult -> {
|
||||
val candidate = (baseResolvedCall as SingleCallResolutionResult).resultCallAtom
|
||||
|
||||
val resultSubstitutor = baseResolvedCall.constraintSystem.buildResultingSubstitutor(typeSystemContext)
|
||||
val resultSubstitutor =
|
||||
baseResolvedCall.constraintSystem.getBuilder().currentStorage().buildResultingSubstitutor(typeSystemContext)
|
||||
if (context.inferenceSession.writeOnlyStubs(baseResolvedCall)) {
|
||||
val stub = createStubResolvedCallAndWriteItToTrace<CallableDescriptor>(
|
||||
candidate,
|
||||
|
||||
@@ -541,7 +541,7 @@ class PSICallResolver(
|
||||
|
||||
val psiKotlinCall = variable.resolvedCall.atom.psiKotlinCall
|
||||
|
||||
val variableResult = PartialCallResolutionResult(variable.resolvedCall, listOf(), variable.getSystem().asReadOnlyStorage())
|
||||
val variableResult = PartialCallResolutionResult(variable.resolvedCall, listOf(), variable.getSystem())
|
||||
|
||||
return SubKotlinCallArgumentImpl(
|
||||
CallMaker.makeExternalValueArgument((variableReceiver.receiverValue as ExpressionReceiver).expression),
|
||||
|
||||
+6
-4
@@ -65,7 +65,8 @@ abstract class StubTypesBasedInferenceSession<D : CallableDescriptor>(
|
||||
}
|
||||
|
||||
override fun currentConstraintSystem(): ConstraintStorage {
|
||||
return partiallyResolvedCallsInfo.lastOrNull()?.callResolutionResult?.constraintSystem ?: ConstraintStorage.Empty
|
||||
return partiallyResolvedCallsInfo.lastOrNull()?.callResolutionResult?.constraintSystem?.getBuilder()?.currentStorage()
|
||||
?: ConstraintStorage.Empty
|
||||
}
|
||||
|
||||
override fun callCompleted(resolvedAtom: ResolvedAtom): Boolean =
|
||||
@@ -116,7 +117,7 @@ abstract class StubTypesBasedInferenceSession<D : CallableDescriptor>(
|
||||
for (callInfo in listOf(goodCandidate, badCandidate)) {
|
||||
val atomsToAnalyze = mutableListOf<ResolvedAtom>(callInfo.callResolutionResult)
|
||||
val system = NewConstraintSystemImpl(callComponents.constraintInjector, builtIns, callComponents.kotlinTypeRefiner).apply {
|
||||
addOtherSystem(callInfo.callResolutionResult.constraintSystem)
|
||||
addOtherSystem(callInfo.callResolutionResult.constraintSystem.getBuilder().currentStorage())
|
||||
/*
|
||||
* This is needed for very stupid case, when we have some delegate with good `getValue` and bad `setValue` that
|
||||
* was provided by some function call with generic (e.g. var x by lazy { "" })
|
||||
@@ -129,7 +130,8 @@ abstract class StubTypesBasedInferenceSession<D : CallableDescriptor>(
|
||||
* stub atoms in order to call completer doesn't fail
|
||||
*/
|
||||
if (callInfo === badCandidate) {
|
||||
for ((typeVariable, fixedType) in allCandidates[0].resolutionResult.constraintSystem.fixedTypeVariables) {
|
||||
val storage = allCandidates[0].resolutionResult.constraintSystem.getBuilder().currentStorage()
|
||||
for ((typeVariable, fixedType) in storage.fixedTypeVariables) {
|
||||
if (typeVariable in this.notFixedTypeVariables) {
|
||||
val type = (typeVariable as TypeConstructor).typeForTypeVariable()
|
||||
addEqualityConstraint(
|
||||
@@ -178,7 +180,7 @@ abstract class StubTypesBasedInferenceSession<D : CallableDescriptor>(
|
||||
commonSystem: NewConstraintSystem
|
||||
): CallResolutionResult {
|
||||
val diagnostics = diagnosticsHolder.getDiagnostics() + callResolutionResult.diagnostics + commonSystem.errors.asDiagnostics()
|
||||
return CompletedCallResolutionResult(callResolutionResult.resultCallAtom, diagnostics, commonSystem.asReadOnlyStorage())
|
||||
return CompletedCallResolutionResult(callResolutionResult.resultCallAtom, diagnostics, commonSystem)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user