Cleanup ConstraintStorage.buildResultingSubstitutor

This commit is contained in:
Simon Ogorodnik
2019-04-08 15:47:35 +03:00
parent 57a3b1a773
commit 2ea7fb8801
4 changed files with 27 additions and 19 deletions
@@ -116,7 +116,7 @@ class CoroutineInferenceSession(
*
* while substitutor from parameter map non-fixed types to the original type variable
* */
val callSubstitutor = storage.buildResultingSubstitutor(commonSystem) as NewTypeSubstitutor // substitutor only for fixed variables
val callSubstitutor = storage.buildResultingSubstitutor(commonSystem) // substitutor only for fixed variables
for (initialConstraint in storage.initialConstraints) {
val lower = nonFixedToVariablesSubstitutor.safeSubstitute(callSubstitutor.safeSubstitute(initialConstraint.a as UnwrappedType)) // TODO: SUB
@@ -49,6 +49,7 @@ import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer
import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
import org.jetbrains.kotlin.types.model.TypeSystemInferenceExtensionContextDelegate
import org.jetbrains.kotlin.types.typeUtil.contains
import org.jetbrains.kotlin.utils.addToStdlib.cast
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@@ -66,7 +67,8 @@ class KotlinToResolvedCallTransformer(
private val additionalDiagnosticReporter: AdditionalDiagnosticReporter,
private val moduleDescriptor: ModuleDescriptor,
private val dataFlowValueFactory: DataFlowValueFactory,
private val builtIns: KotlinBuiltIns
private val builtIns: KotlinBuiltIns,
private val typeSystemContext: TypeSystemInferenceExtensionContextDelegate
) {
companion object {
private val REPORT_MISSING_NEW_INFERENCE_DIAGNOSTIC
@@ -106,7 +108,7 @@ class KotlinToResolvedCallTransformer(
is CompletedCallResolutionResult, is ErrorCallResolutionResult -> {
val candidate = (baseResolvedCall as SingleCallResolutionResult).resultCallAtom
val resultSubstitutor = baseResolvedCall.constraintSystem.buildResultingSubstitutor()
val resultSubstitutor = baseResolvedCall.constraintSystem.buildResultingSubstitutor(typeSystemContext)
if (context.inferenceSession.writeOnlyStubs()) {
val stub = createStubResolvedCallAndWriteItToTrace<CallableDescriptor>(
candidate,
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.resolve.scopes.*
import org.jetbrains.kotlin.resolve.scopes.receivers.*
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.expressions.*
import org.jetbrains.kotlin.types.model.TypeSystemInferenceExtensionContext
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
import java.util.*
@@ -190,7 +191,9 @@ class PSICallResolver(
): OverloadResolutionResults<D> {
if (result is AllCandidatesResolutionResult) {
val resolvedCalls = result.allCandidates.map { (candidate, diagnostics) ->
val resultingSubstitutor = candidate.getSystem().asReadOnlyStorage().buildResultingSubstitutor()
val system = candidate.getSystem()
val resultingSubstitutor =
system.asReadOnlyStorage().buildResultingSubstitutor(system as TypeSystemInferenceExtensionContext)
kotlinToResolvedCallTransformer.transformToResolvedCall<D>(
candidate.resolvedCall, null, resultingSubstitutor, diagnostics