[NI] Extract common parts from KotlinConstraintSystemCompleter
This commit is contained in:
+3
-3
@@ -9,8 +9,8 @@ import org.jetbrains.kotlin.fir.resolve.calls.Candidate
|
|||||||
import org.jetbrains.kotlin.fir.types.ConeIntegerLiteralType
|
import org.jetbrains.kotlin.fir.types.ConeIntegerLiteralType
|
||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter.Context
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.TrivialConstraintTypeInferenceOracle
|
import org.jetbrains.kotlin.resolve.calls.inference.components.TrivialConstraintTypeInferenceOracle
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.Constraint
|
import org.jetbrains.kotlin.resolve.calls.inference.model.Constraint
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.VariableWithConstraints
|
import org.jetbrains.kotlin.resolve.calls.inference.model.VariableWithConstraints
|
||||||
@@ -40,7 +40,7 @@ fun Candidate.computeCompletionMode(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private typealias CsCompleterContext = Context
|
private typealias CsCompleterContext = ConstraintSystemCompletionContext
|
||||||
|
|
||||||
private class CalculatorForNestedCall(
|
private class CalculatorForNestedCall(
|
||||||
private val candidate: Candidate,
|
private val candidate: Candidate,
|
||||||
|
|||||||
+8
-11
@@ -13,10 +13,7 @@ import org.jetbrains.kotlin.fir.returnExpressions
|
|||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
import org.jetbrains.kotlin.resolve.calls.inference.components.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.TypeVariableDirectionCalculator
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.VariableFixationFinder
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImpl
|
import org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImpl
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
|
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.VariableWithConstraints
|
import org.jetbrains.kotlin.resolve.calls.inference.model.VariableWithConstraints
|
||||||
@@ -31,7 +28,7 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents) {
|
|||||||
val variableFixationFinder = VariableFixationFinder(components.inferenceComponents.trivialConstraintTypeInferenceOracle)
|
val variableFixationFinder = VariableFixationFinder(components.inferenceComponents.trivialConstraintTypeInferenceOracle)
|
||||||
|
|
||||||
fun complete(
|
fun complete(
|
||||||
c: KotlinConstraintSystemCompleter.Context,
|
c: ConstraintSystemCompletionContext,
|
||||||
completionMode: ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
topLevelAtoms: List<FirStatement>,
|
topLevelAtoms: List<FirStatement>,
|
||||||
candidateReturnType: ConeKotlinType,
|
candidateReturnType: ConeKotlinType,
|
||||||
@@ -77,7 +74,7 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun resolveLambdaOrCallableReferenceWithTypeVariableAsExpectedType(
|
private fun resolveLambdaOrCallableReferenceWithTypeVariableAsExpectedType(
|
||||||
c: KotlinConstraintSystemCompleter.Context,
|
c: ConstraintSystemCompletionContext,
|
||||||
variableForFixation: VariableFixationFinder.VariableForFixation,
|
variableForFixation: VariableFixationFinder.VariableForFixation,
|
||||||
postponedAtoms: List<PostponedResolvedAtom>,
|
postponedAtoms: List<PostponedResolvedAtom>,
|
||||||
/*diagnosticsHolder: KotlinDiagnosticsHolder,*/
|
/*diagnosticsHolder: KotlinDiagnosticsHolder,*/
|
||||||
@@ -122,7 +119,7 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private inline fun <T : PostponedResolvedAtom, V : ConeTypeVariable> T.preparePostponedAtomWithTypeVariableAsExpectedType(
|
private inline fun <T : PostponedResolvedAtom, V : ConeTypeVariable> T.preparePostponedAtomWithTypeVariableAsExpectedType(
|
||||||
c: KotlinConstraintSystemCompleter.Context,
|
c: ConstraintSystemCompletionContext,
|
||||||
csBuilder: ConstraintSystemBuilder,
|
csBuilder: ConstraintSystemBuilder,
|
||||||
variable: ConeTypeVariable,
|
variable: ConeTypeVariable,
|
||||||
parameterTypes: Array<out ConeKotlinType?>?,
|
parameterTypes: Array<out ConeKotlinType?>?,
|
||||||
@@ -161,7 +158,7 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents) {
|
|||||||
|
|
||||||
|
|
||||||
private fun getOrderedAllTypeVariables(
|
private fun getOrderedAllTypeVariables(
|
||||||
c: KotlinConstraintSystemCompleter.Context,
|
c: ConstraintSystemCompletionContext,
|
||||||
topLevelAtoms: List<FirStatement>,
|
topLevelAtoms: List<FirStatement>,
|
||||||
collectVariablesFromContext: Boolean
|
collectVariablesFromContext: Boolean
|
||||||
): List<TypeConstructorMarker> {
|
): List<TypeConstructorMarker> {
|
||||||
@@ -199,7 +196,7 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun fixVariable(
|
private fun fixVariable(
|
||||||
c: KotlinConstraintSystemCompleter.Context,
|
c: ConstraintSystemCompletionContext,
|
||||||
topLevelType: KotlinTypeMarker,
|
topLevelType: KotlinTypeMarker,
|
||||||
variableWithConstraints: VariableWithConstraints,
|
variableWithConstraints: VariableWithConstraints,
|
||||||
postponedResolveKtPrimitives: List<PostponedResolvedAtom>
|
postponedResolveKtPrimitives: List<PostponedResolvedAtom>
|
||||||
@@ -210,7 +207,7 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun analyzePostponeArgumentIfPossible(
|
private fun analyzePostponeArgumentIfPossible(
|
||||||
c: KotlinConstraintSystemCompleter.Context,
|
c: ConstraintSystemCompletionContext,
|
||||||
topLevelAtoms: List<FirStatement>,
|
topLevelAtoms: List<FirStatement>,
|
||||||
analyze: (PostponedResolvedAtom) -> Unit
|
analyze: (PostponedResolvedAtom) -> Unit
|
||||||
): Boolean {
|
): Boolean {
|
||||||
@@ -240,7 +237,7 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents) {
|
|||||||
return notAnalyzedArguments
|
return notAnalyzedArguments
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun canWeAnalyzeIt(c: KotlinConstraintSystemCompleter.Context, argument: PostponedResolvedAtomMarker): Boolean {
|
private fun canWeAnalyzeIt(c: ConstraintSystemCompletionContext, argument: PostponedResolvedAtomMarker): Boolean {
|
||||||
if (argument.analyzed) return false
|
if (argument.analyzed) return false
|
||||||
return argument.inputTypes.all { c.containsOnlyFixedOrPostponedVariables(it) }
|
return argument.inputTypes.all { c.containsOnlyFixedOrPostponedVariables(it) }
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.fir.types.ConeTypeVariable
|
|||||||
import org.jetbrains.kotlin.fir.types.ConeTypeVariableTypeConstructor
|
import org.jetbrains.kotlin.fir.types.ConeTypeVariableTypeConstructor
|
||||||
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.buildAbstractResultingSubstitutor
|
import org.jetbrains.kotlin.resolve.calls.inference.buildAbstractResultingSubstitutor
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintKind
|
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintKind
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.CoroutinePosition
|
import org.jetbrains.kotlin.resolve.calls.inference.model.CoroutinePosition
|
||||||
@@ -94,7 +94,7 @@ class FirBuilderInferenceSession(
|
|||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
components.callCompleter.completer.complete(
|
components.callCompleter.completer.complete(
|
||||||
context,
|
context,
|
||||||
KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode.FULL,
|
ConstraintSystemCompletionMode.FULL,
|
||||||
partiallyResolvedCalls.map { it.first as FirStatement },
|
partiallyResolvedCalls.map { it.first as FirStatement },
|
||||||
components.session.builtinTypes.unitType.type,
|
components.session.builtinTypes.unitType.type,
|
||||||
collectVariablesFromContext = true
|
collectVariablesFromContext = true
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
|||||||
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.buildAbstractResultingSubstitutor
|
import org.jetbrains.kotlin.resolve.calls.inference.buildAbstractResultingSubstitutor
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
|
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
|
||||||
import org.jetbrains.kotlin.types.TypeApproximatorConfiguration
|
import org.jetbrains.kotlin.types.TypeApproximatorConfiguration
|
||||||
import org.jetbrains.kotlin.types.model.StubTypeMarker
|
import org.jetbrains.kotlin.types.model.StubTypeMarker
|
||||||
|
|||||||
+3
-2
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.fir.types.*
|
|||||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.NewConstraintSystem
|
import org.jetbrains.kotlin.resolve.calls.inference.NewConstraintSystem
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.buildAbstractResultingSubstitutor
|
import org.jetbrains.kotlin.resolve.calls.inference.buildAbstractResultingSubstitutor
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
|
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
|
||||||
@@ -69,7 +70,7 @@ class FirDelegatedPropertyInferenceSession(
|
|||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
components.callCompleter.completer.complete(
|
components.callCompleter.completer.complete(
|
||||||
commonSystem.asConstraintSystemCompleterContext(),
|
commonSystem.asConstraintSystemCompleterContext(),
|
||||||
KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode.FULL,
|
ConstraintSystemCompletionMode.FULL,
|
||||||
resolvedCalls as List<FirStatement>,
|
resolvedCalls as List<FirStatement>,
|
||||||
unitType
|
unitType
|
||||||
) {
|
) {
|
||||||
@@ -137,4 +138,4 @@ class FirDelegatedPropertyInferenceSession(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun <T> writeOnlyStubs(call: T): Boolean where T : FirResolvable, T : FirStatement = false
|
override fun <T> writeOnlyStubs(call: T): Boolean where T : FirResolvable, T : FirStatement = false
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors
|
|||||||
import org.jetbrains.kotlin.resolve.calls.components.*
|
import org.jetbrains.kotlin.resolve.calls.components.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.NewConstraintSystem
|
import org.jetbrains.kotlin.resolve.calls.inference.NewConstraintSystem
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.DelegatedPropertyConstraintPositionImpl
|
import org.jetbrains.kotlin.resolve.calls.inference.model.DelegatedPropertyConstraintPositionImpl
|
||||||
@@ -82,7 +83,7 @@ class DelegatedPropertyInferenceSession(
|
|||||||
override fun inferPostponedVariables(
|
override fun inferPostponedVariables(
|
||||||
lambda: ResolvedLambdaAtom,
|
lambda: ResolvedLambdaAtom,
|
||||||
initialStorage: ConstraintStorage,
|
initialStorage: ConstraintStorage,
|
||||||
completionMode: KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
diagnosticsHolder: KotlinDiagnosticsHolder
|
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||||
): Map<TypeConstructor, UnwrappedType> = emptyMap()
|
): Map<TypeConstructor, UnwrappedType> = emptyMap()
|
||||||
|
|
||||||
@@ -104,7 +105,7 @@ class InferenceSessionForExistingCandidates(private val resolveReceiverIndepende
|
|||||||
override fun inferPostponedVariables(
|
override fun inferPostponedVariables(
|
||||||
lambda: ResolvedLambdaAtom,
|
lambda: ResolvedLambdaAtom,
|
||||||
initialStorage: ConstraintStorage,
|
initialStorage: ConstraintStorage,
|
||||||
completionMode: KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
diagnosticsHolder: KotlinDiagnosticsHolder
|
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||||
): Map<TypeConstructor, UnwrappedType> = emptyMap()
|
): Map<TypeConstructor, UnwrappedType> = emptyMap()
|
||||||
|
|
||||||
@@ -116,7 +117,7 @@ class InferenceSessionForExistingCandidates(private val resolveReceiverIndepende
|
|||||||
|
|
||||||
override fun computeCompletionMode(
|
override fun computeCompletionMode(
|
||||||
candidate: KotlinResolutionCandidate
|
candidate: KotlinResolutionCandidate
|
||||||
): KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode? = null
|
): ConstraintSystemCompletionMode? = null
|
||||||
|
|
||||||
override fun resolveReceiverIndependently(): Boolean = resolveReceiverIndependently
|
override fun resolveReceiverIndependently(): Boolean = resolveReceiverIndependently
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.resolve.calls.components.NewConstraintSystemImpl
|
|||||||
import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzer
|
import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzer
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.stableType
|
import org.jetbrains.kotlin.resolve.calls.components.stableType
|
||||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor
|
import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutorByConstructorMap
|
import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutorByConstructorMap
|
||||||
@@ -169,7 +170,7 @@ class CoroutineInferenceSession(
|
|||||||
override fun inferPostponedVariables(
|
override fun inferPostponedVariables(
|
||||||
lambda: ResolvedLambdaAtom,
|
lambda: ResolvedLambdaAtom,
|
||||||
initialStorage: ConstraintStorage,
|
initialStorage: ConstraintStorage,
|
||||||
completionMode: KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
diagnosticsHolder: KotlinDiagnosticsHolder,
|
diagnosticsHolder: KotlinDiagnosticsHolder,
|
||||||
): Map<TypeConstructor, UnwrappedType>? {
|
): Map<TypeConstructor, UnwrappedType>? {
|
||||||
val (commonSystem, effectivelyEmptyConstraintSystem) = buildCommonSystem(initialStorage)
|
val (commonSystem, effectivelyEmptyConstraintSystem) = buildCommonSystem(initialStorage)
|
||||||
|
|||||||
+2
-1
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
|||||||
import org.jetbrains.kotlin.resolve.calls.components.*
|
import org.jetbrains.kotlin.resolve.calls.components.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.NewConstraintSystem
|
import org.jetbrains.kotlin.resolve.calls.inference.NewConstraintSystem
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
|
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
|
||||||
@@ -81,7 +82,7 @@ abstract class ManyCandidatesResolver<D : CallableDescriptor>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun runCompletion(constraintSystem: NewConstraintSystem, atoms: List<ResolvedAtom>) {
|
fun runCompletion(constraintSystem: NewConstraintSystem, atoms: List<ResolvedAtom>) {
|
||||||
val completionMode = KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode.FULL
|
val completionMode = ConstraintSystemCompletionMode.FULL
|
||||||
kotlinConstraintSystemCompleter.runCompletion(
|
kotlinConstraintSystemCompleter.runCompletion(
|
||||||
constraintSystem.asConstraintSystemCompleterContext(),
|
constraintSystem.asConstraintSystemCompleterContext(),
|
||||||
completionMode,
|
completionMode,
|
||||||
|
|||||||
+4
-3
@@ -5,8 +5,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.resolve.calls.components
|
package org.jetbrains.kotlin.resolve.calls.components
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.TrivialConstraintTypeInferenceOracle
|
import org.jetbrains.kotlin.resolve.calls.inference.components.TrivialConstraintTypeInferenceOracle
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.Constraint
|
import org.jetbrains.kotlin.resolve.calls.inference.model.Constraint
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.VariableWithConstraints
|
import org.jetbrains.kotlin.resolve.calls.inference.model.VariableWithConstraints
|
||||||
@@ -18,7 +19,7 @@ import org.jetbrains.kotlin.types.model.*
|
|||||||
import org.jetbrains.kotlin.utils.newLinkedHashMapWithExpectedSize
|
import org.jetbrains.kotlin.utils.newLinkedHashMapWithExpectedSize
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
typealias CsCompleterContext = KotlinConstraintSystemCompleter.Context
|
typealias CsCompleterContext = ConstraintSystemCompletionContext
|
||||||
|
|
||||||
class CompletionModeCalculator {
|
class CompletionModeCalculator {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -238,4 +239,4 @@ class CompletionModeCalculator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.resolve.calls.components
|
package org.jetbrains.kotlin.resolve.calls.components
|
||||||
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||||
import org.jetbrains.kotlin.types.TypeConstructor
|
import org.jetbrains.kotlin.types.TypeConstructor
|
||||||
@@ -22,7 +22,7 @@ interface InferenceSession {
|
|||||||
override fun inferPostponedVariables(
|
override fun inferPostponedVariables(
|
||||||
lambda: ResolvedLambdaAtom,
|
lambda: ResolvedLambdaAtom,
|
||||||
initialStorage: ConstraintStorage,
|
initialStorage: ConstraintStorage,
|
||||||
completionMode: KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
diagnosticsHolder: KotlinDiagnosticsHolder
|
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||||
): Map<TypeConstructor, UnwrappedType> = emptyMap()
|
): Map<TypeConstructor, UnwrappedType> = emptyMap()
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ interface InferenceSession {
|
|||||||
override fun shouldCompleteResolvedSubAtomsOf(resolvedCallAtom: ResolvedCallAtom) = true
|
override fun shouldCompleteResolvedSubAtomsOf(resolvedCallAtom: ResolvedCallAtom) = true
|
||||||
override fun computeCompletionMode(
|
override fun computeCompletionMode(
|
||||||
candidate: KotlinResolutionCandidate
|
candidate: KotlinResolutionCandidate
|
||||||
): KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode? = null
|
): ConstraintSystemCompletionMode? = null
|
||||||
|
|
||||||
override fun resolveReceiverIndependently(): Boolean = false
|
override fun resolveReceiverIndependently(): Boolean = false
|
||||||
}
|
}
|
||||||
@@ -45,14 +45,14 @@ interface InferenceSession {
|
|||||||
fun inferPostponedVariables(
|
fun inferPostponedVariables(
|
||||||
lambda: ResolvedLambdaAtom,
|
lambda: ResolvedLambdaAtom,
|
||||||
initialStorage: ConstraintStorage,
|
initialStorage: ConstraintStorage,
|
||||||
completionMode: KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
diagnosticsHolder: KotlinDiagnosticsHolder
|
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||||
): Map<TypeConstructor, UnwrappedType>?
|
): Map<TypeConstructor, UnwrappedType>?
|
||||||
|
|
||||||
fun writeOnlyStubs(callInfo: SingleCallResolutionResult): Boolean
|
fun writeOnlyStubs(callInfo: SingleCallResolutionResult): Boolean
|
||||||
fun callCompleted(resolvedAtom: ResolvedAtom): Boolean
|
fun callCompleted(resolvedAtom: ResolvedAtom): Boolean
|
||||||
fun shouldCompleteResolvedSubAtomsOf(resolvedCallAtom: ResolvedCallAtom): Boolean
|
fun shouldCompleteResolvedSubAtomsOf(resolvedCallAtom: ResolvedCallAtom): Boolean
|
||||||
fun computeCompletionMode(candidate: KotlinResolutionCandidate): KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode?
|
fun computeCompletionMode(candidate: KotlinResolutionCandidate): ConstraintSystemCompletionMode?
|
||||||
fun resolveReceiverIndependently(): Boolean
|
fun resolveReceiverIndependently(): Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor
|
|||||||
import org.jetbrains.kotlin.resolve.calls.inference.NewConstraintSystem
|
import org.jetbrains.kotlin.resolve.calls.inference.NewConstraintSystem
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.addEqualityConstraintIfCompatible
|
import org.jetbrains.kotlin.resolve.calls.inference.addEqualityConstraintIfCompatible
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.TrivialConstraintTypeInferenceOracle
|
import org.jetbrains.kotlin.resolve.calls.inference.components.TrivialConstraintTypeInferenceOracle
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage.Empty.hasContradiction
|
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage.Empty.hasContradiction
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ExpectedTypeConstraintPositionImpl
|
import org.jetbrains.kotlin.resolve.calls.inference.model.ExpectedTypeConstraintPositionImpl
|
||||||
|
|||||||
+4
-4
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
|||||||
import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations
|
import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.addSubsystemFromArgument
|
import org.jetbrains.kotlin.resolve.calls.inference.addSubsystemFromArgument
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.CoroutinePosition
|
import org.jetbrains.kotlin.resolve.calls.inference.model.CoroutinePosition
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.LambdaArgumentConstraintPositionImpl
|
import org.jetbrains.kotlin.resolve.calls.inference.model.LambdaArgumentConstraintPositionImpl
|
||||||
@@ -47,7 +47,7 @@ class PostponedArgumentsAnalyzer(
|
|||||||
c: Context,
|
c: Context,
|
||||||
resolutionCallbacks: KotlinResolutionCallbacks,
|
resolutionCallbacks: KotlinResolutionCallbacks,
|
||||||
argument: ResolvedAtom,
|
argument: ResolvedAtom,
|
||||||
completionMode: KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
diagnosticsHolder: KotlinDiagnosticsHolder
|
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||||
) {
|
) {
|
||||||
when (argument) {
|
when (argument) {
|
||||||
@@ -89,7 +89,7 @@ class PostponedArgumentsAnalyzer(
|
|||||||
c: Context,
|
c: Context,
|
||||||
resolutionCallbacks: KotlinResolutionCallbacks,
|
resolutionCallbacks: KotlinResolutionCallbacks,
|
||||||
lambda: ResolvedLambdaAtom,
|
lambda: ResolvedLambdaAtom,
|
||||||
completionMode: KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
diagnosticHolder: KotlinDiagnosticsHolder,
|
diagnosticHolder: KotlinDiagnosticsHolder,
|
||||||
): ReturnArgumentsAnalysisResult {
|
): ReturnArgumentsAnalysisResult {
|
||||||
val substitutorAndStubsForLambdaAnalysis = c.createSubstituteFunctorForLambdaAnalysis()
|
val substitutorAndStubsForLambdaAnalysis = c.createSubstituteFunctorForLambdaAnalysis()
|
||||||
@@ -156,7 +156,7 @@ class PostponedArgumentsAnalyzer(
|
|||||||
c: Context,
|
c: Context,
|
||||||
lambda: ResolvedLambdaAtom,
|
lambda: ResolvedLambdaAtom,
|
||||||
returnArgumentsAnalysisResult: ReturnArgumentsAnalysisResult,
|
returnArgumentsAnalysisResult: ReturnArgumentsAnalysisResult,
|
||||||
completionMode: KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
diagnosticHolder: KotlinDiagnosticsHolder,
|
diagnosticHolder: KotlinDiagnosticsHolder,
|
||||||
substitute: (KotlinType) -> UnwrappedType = c.createSubstituteFunctorForLambdaAnalysis().substitute
|
substitute: (KotlinType) -> UnwrappedType = c.createSubstituteFunctorForLambdaAnalysis().substitute
|
||||||
) {
|
) {
|
||||||
|
|||||||
+2
-2
@@ -17,7 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.resolve.calls.inference
|
package org.jetbrains.kotlin.resolve.calls.inference
|
||||||
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzer
|
import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzer
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.PostponedArgumentInputTypesResolver
|
import org.jetbrains.kotlin.resolve.calls.inference.components.PostponedArgumentInputTypesResolver
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintSystemError
|
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintSystemError
|
||||||
@@ -31,7 +31,7 @@ interface NewConstraintSystem {
|
|||||||
// after this method we shouldn't mutate system via ConstraintSystemBuilder
|
// after this method we shouldn't mutate system via ConstraintSystemBuilder
|
||||||
fun asReadOnlyStorage(): ConstraintStorage
|
fun asReadOnlyStorage(): ConstraintStorage
|
||||||
|
|
||||||
fun asConstraintSystemCompleterContext(): KotlinConstraintSystemCompleter.Context
|
fun asConstraintSystemCompleterContext(): ConstraintSystemCompletionContext
|
||||||
fun asPostponedArgumentsAnalyzerContext(): PostponedArgumentsAnalyzer.Context
|
fun asPostponedArgumentsAnalyzerContext(): PostponedArgumentsAnalyzer.Context
|
||||||
fun asPostponedArgumentInputTypesResolverContext(): PostponedArgumentInputTypesResolver.Context
|
fun asPostponedArgumentInputTypesResolverContext(): PostponedArgumentInputTypesResolver.Context
|
||||||
}
|
}
|
||||||
|
|||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.resolve.calls.inference.components
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintSystemError
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.inference.model.VariableWithConstraints
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedAtom
|
||||||
|
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||||
|
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
|
||||||
|
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
||||||
|
|
||||||
|
interface ConstraintSystemCompletionContext : VariableFixationFinder.Context, ResultTypeResolver.Context {
|
||||||
|
val allTypeVariables: Map<TypeConstructorMarker, TypeVariableMarker>
|
||||||
|
override val notFixedTypeVariables: Map<TypeConstructorMarker, VariableWithConstraints>
|
||||||
|
override val postponedTypeVariables: List<TypeVariableMarker>
|
||||||
|
|
||||||
|
fun getBuilder(): ConstraintSystemBuilder
|
||||||
|
|
||||||
|
// type can be proper if it not contains not fixed type variables
|
||||||
|
fun canBeProper(type: KotlinTypeMarker): Boolean
|
||||||
|
|
||||||
|
fun containsOnlyFixedOrPostponedVariables(type: KotlinTypeMarker): Boolean
|
||||||
|
|
||||||
|
// mutable operations
|
||||||
|
fun addError(error: ConstraintSystemError)
|
||||||
|
|
||||||
|
fun fixVariable(variable: TypeVariableMarker, resultType: KotlinTypeMarker, atom: ResolvedAtom?)
|
||||||
|
|
||||||
|
fun asPostponedArgumentInputTypesResolverContext(): PostponedArgumentInputTypesResolver.Context
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.resolve.calls.inference.components
|
||||||
|
|
||||||
|
enum class ConstraintSystemCompletionMode {
|
||||||
|
FULL,
|
||||||
|
PARTIAL,
|
||||||
|
UNTIL_FIRST_LAMBDA
|
||||||
|
}
|
||||||
+13
-41
@@ -6,11 +6,9 @@
|
|||||||
package org.jetbrains.kotlin.resolve.calls.inference.components
|
package org.jetbrains.kotlin.resolve.calls.inference.components
|
||||||
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.transformToResolvedLambda
|
import org.jetbrains.kotlin.resolve.calls.components.transformToResolvedLambda
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.*
|
import org.jetbrains.kotlin.resolve.calls.inference.model.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.*
|
||||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
|
||||||
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
|
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
|
||||||
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
||||||
import org.jetbrains.kotlin.types.model.safeSubstitute
|
import org.jetbrains.kotlin.types.model.safeSubstitute
|
||||||
@@ -24,34 +22,8 @@ class KotlinConstraintSystemCompleter(
|
|||||||
) {
|
) {
|
||||||
private val postponedArgumentInputTypesResolver = PostponedArgumentInputTypesResolver(resultTypeResolver, variableFixationFinder)
|
private val postponedArgumentInputTypesResolver = PostponedArgumentInputTypesResolver(resultTypeResolver, variableFixationFinder)
|
||||||
|
|
||||||
enum class ConstraintSystemCompletionMode {
|
|
||||||
FULL,
|
|
||||||
PARTIAL,
|
|
||||||
UNTIL_FIRST_LAMBDA
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Context : VariableFixationFinder.Context, ResultTypeResolver.Context {
|
|
||||||
val allTypeVariables: Map<TypeConstructorMarker, TypeVariableMarker>
|
|
||||||
override val notFixedTypeVariables: Map<TypeConstructorMarker, VariableWithConstraints>
|
|
||||||
override val postponedTypeVariables: List<TypeVariableMarker>
|
|
||||||
|
|
||||||
fun getBuilder(): ConstraintSystemBuilder
|
|
||||||
|
|
||||||
// type can be proper if it not contains not fixed type variables
|
|
||||||
fun canBeProper(type: KotlinTypeMarker): Boolean
|
|
||||||
|
|
||||||
fun containsOnlyFixedOrPostponedVariables(type: KotlinTypeMarker): Boolean
|
|
||||||
|
|
||||||
// mutable operations
|
|
||||||
fun addError(error: ConstraintSystemError)
|
|
||||||
|
|
||||||
fun fixVariable(variable: TypeVariableMarker, resultType: KotlinTypeMarker, atom: ResolvedAtom?)
|
|
||||||
|
|
||||||
fun asPostponedArgumentInputTypesResolverContext(): PostponedArgumentInputTypesResolver.Context
|
|
||||||
}
|
|
||||||
|
|
||||||
fun runCompletion(
|
fun runCompletion(
|
||||||
c: Context,
|
c: ConstraintSystemCompletionContext,
|
||||||
completionMode: ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
topLevelAtoms: List<ResolvedAtom>,
|
topLevelAtoms: List<ResolvedAtom>,
|
||||||
topLevelType: UnwrappedType,
|
topLevelType: UnwrappedType,
|
||||||
@@ -69,7 +41,7 @@ class KotlinConstraintSystemCompleter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun completeConstraintSystem(
|
fun completeConstraintSystem(
|
||||||
c: Context,
|
c: ConstraintSystemCompletionContext,
|
||||||
topLevelType: UnwrappedType,
|
topLevelType: UnwrappedType,
|
||||||
topLevelAtoms: List<ResolvedAtom>,
|
topLevelAtoms: List<ResolvedAtom>,
|
||||||
completionMode: ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
@@ -86,7 +58,7 @@ class KotlinConstraintSystemCompleter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Context.runCompletion(
|
private fun ConstraintSystemCompletionContext.runCompletion(
|
||||||
completionMode: ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
topLevelAtoms: List<ResolvedAtom>,
|
topLevelAtoms: List<ResolvedAtom>,
|
||||||
topLevelType: UnwrappedType,
|
topLevelType: UnwrappedType,
|
||||||
@@ -171,7 +143,7 @@ class KotlinConstraintSystemCompleter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Context.analyzeArgumentWithFixedParameterTypes(
|
private fun ConstraintSystemCompletionContext.analyzeArgumentWithFixedParameterTypes(
|
||||||
postponedArguments: List<PostponedResolvedAtom>,
|
postponedArguments: List<PostponedResolvedAtom>,
|
||||||
analyze: (PostponedResolvedAtom) -> Unit
|
analyze: (PostponedResolvedAtom) -> Unit
|
||||||
): Boolean {
|
): Boolean {
|
||||||
@@ -185,7 +157,7 @@ class KotlinConstraintSystemCompleter(
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Context.analyzeNextReadyPostponedArgument(
|
private fun ConstraintSystemCompletionContext.analyzeNextReadyPostponedArgument(
|
||||||
postponedArguments: List<PostponedResolvedAtom>,
|
postponedArguments: List<PostponedResolvedAtom>,
|
||||||
completionMode: ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
analyze: (PostponedResolvedAtom) -> Unit
|
analyze: (PostponedResolvedAtom) -> Unit
|
||||||
@@ -239,7 +211,7 @@ class KotlinConstraintSystemCompleter(
|
|||||||
return atom.transformToResolvedLambda(csBuilder, diagnosticsHolder, expectedType, returnVariable)
|
return atom.transformToResolvedLambda(csBuilder, diagnosticsHolder, expectedType, returnVariable)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Context.hasLambdaToAnalyze(
|
private fun ConstraintSystemCompletionContext.hasLambdaToAnalyze(
|
||||||
postponedArguments: List<PostponedResolvedAtom>
|
postponedArguments: List<PostponedResolvedAtom>
|
||||||
): Boolean {
|
): Boolean {
|
||||||
return analyzeArgumentWithFixedParameterTypes(postponedArguments) {}
|
return analyzeArgumentWithFixedParameterTypes(postponedArguments) {}
|
||||||
@@ -248,11 +220,11 @@ class KotlinConstraintSystemCompleter(
|
|||||||
private fun findPostponedArgumentWithRevisableExpectedType(postponedArguments: List<PostponedResolvedAtom>) =
|
private fun findPostponedArgumentWithRevisableExpectedType(postponedArguments: List<PostponedResolvedAtom>) =
|
||||||
postponedArguments.firstOrNull { argument -> argument is PostponedAtomWithRevisableExpectedType }
|
postponedArguments.firstOrNull { argument -> argument is PostponedAtomWithRevisableExpectedType }
|
||||||
|
|
||||||
private fun Context.findPostponedArgumentWithFixedOrPostponedInputTypes(postponedArguments: List<PostponedResolvedAtom>) =
|
private fun ConstraintSystemCompletionContext.findPostponedArgumentWithFixedOrPostponedInputTypes(postponedArguments: List<PostponedResolvedAtom>) =
|
||||||
postponedArguments.firstOrNull { argument -> argument.inputTypes.all { containsOnlyFixedOrPostponedVariables(it) } }
|
postponedArguments.firstOrNull { argument -> argument.inputTypes.all { containsOnlyFixedOrPostponedVariables(it) } }
|
||||||
|
|
||||||
private fun fixVariable(
|
private fun fixVariable(
|
||||||
c: Context,
|
c: ConstraintSystemCompletionContext,
|
||||||
variableWithConstraints: VariableWithConstraints,
|
variableWithConstraints: VariableWithConstraints,
|
||||||
topLevelAtoms: List<ResolvedAtom>
|
topLevelAtoms: List<ResolvedAtom>
|
||||||
) {
|
) {
|
||||||
@@ -260,7 +232,7 @@ class KotlinConstraintSystemCompleter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun fixVariable(
|
private fun fixVariable(
|
||||||
c: Context,
|
c: ConstraintSystemCompletionContext,
|
||||||
variableWithConstraints: VariableWithConstraints,
|
variableWithConstraints: VariableWithConstraints,
|
||||||
direction: TypeVariableDirectionCalculator.ResolveDirection,
|
direction: TypeVariableDirectionCalculator.ResolveDirection,
|
||||||
topLevelAtoms: List<ResolvedAtom>
|
topLevelAtoms: List<ResolvedAtom>
|
||||||
@@ -270,7 +242,7 @@ class KotlinConstraintSystemCompleter(
|
|||||||
c.fixVariable(variableWithConstraints.typeVariable, resultType, resolvedAtom)
|
c.fixVariable(variableWithConstraints.typeVariable, resultType, resolvedAtom)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Context.fixVariablesOrReportNotEnoughInformation(
|
private fun ConstraintSystemCompletionContext.fixVariablesOrReportNotEnoughInformation(
|
||||||
completionMode: ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
topLevelAtoms: List<ResolvedAtom>,
|
topLevelAtoms: List<ResolvedAtom>,
|
||||||
topLevelType: UnwrappedType,
|
topLevelType: UnwrappedType,
|
||||||
@@ -304,7 +276,7 @@ class KotlinConstraintSystemCompleter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun processVariableWhenNotEnoughInformation(
|
private fun processVariableWhenNotEnoughInformation(
|
||||||
c: Context,
|
c: ConstraintSystemCompletionContext,
|
||||||
variableWithConstraints: VariableWithConstraints,
|
variableWithConstraints: VariableWithConstraints,
|
||||||
topLevelAtoms: List<ResolvedAtom>,
|
topLevelAtoms: List<ResolvedAtom>,
|
||||||
diagnosticsHolder: KotlinDiagnosticsHolder
|
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||||
@@ -331,7 +303,7 @@ class KotlinConstraintSystemCompleter(
|
|||||||
c.fixVariable(typeVariable, resultErrorType, resolvedAtom)
|
c.fixVariable(typeVariable, resultErrorType, resolvedAtom)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Context.getOrderedAllTypeVariables(
|
private fun ConstraintSystemCompletionContext.getOrderedAllTypeVariables(
|
||||||
collectVariablesFromContext: Boolean,
|
collectVariablesFromContext: Boolean,
|
||||||
topLevelAtoms: List<ResolvedAtom>
|
topLevelAtoms: List<ResolvedAtom>
|
||||||
): List<TypeConstructorMarker> {
|
): List<TypeConstructorMarker> {
|
||||||
@@ -383,7 +355,7 @@ class KotlinConstraintSystemCompleter(
|
|||||||
return result.toList()
|
return result.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Context.isThereAnyReadyForFixationVariable(
|
private fun ConstraintSystemCompletionContext.isThereAnyReadyForFixationVariable(
|
||||||
completionMode: ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
topLevelAtoms: List<ResolvedAtom>,
|
topLevelAtoms: List<ResolvedAtom>,
|
||||||
topLevelType: UnwrappedType,
|
topLevelType: UnwrappedType,
|
||||||
|
|||||||
+4
-4
@@ -20,7 +20,7 @@ class PostponedArgumentInputTypesResolver(
|
|||||||
private val resultTypeResolver: ResultTypeResolver,
|
private val resultTypeResolver: ResultTypeResolver,
|
||||||
private val variableFixationFinder: VariableFixationFinder
|
private val variableFixationFinder: VariableFixationFinder
|
||||||
) {
|
) {
|
||||||
interface Context : KotlinConstraintSystemCompleter.Context
|
interface Context : ConstraintSystemCompletionContext
|
||||||
|
|
||||||
private class ParameterTypesInfo(
|
private class ParameterTypesInfo(
|
||||||
val parametersFromDeclaration: List<UnwrappedType?>?,
|
val parametersFromDeclaration: List<UnwrappedType?>?,
|
||||||
@@ -339,7 +339,7 @@ class PostponedArgumentInputTypesResolver(
|
|||||||
fun collectParameterTypesAndBuildNewExpectedTypes(
|
fun collectParameterTypesAndBuildNewExpectedTypes(
|
||||||
c: Context,
|
c: Context,
|
||||||
postponedArguments: List<PostponedAtomWithRevisableExpectedType>,
|
postponedArguments: List<PostponedAtomWithRevisableExpectedType>,
|
||||||
completionMode: KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
dependencyProvider: TypeVariableDependencyInformationProvider
|
dependencyProvider: TypeVariableDependencyInformationProvider
|
||||||
): Boolean {
|
): Boolean {
|
||||||
// We can collect parameter types from declaration in any mode, they can't change during completion.
|
// We can collect parameter types from declaration in any mode, they can't change during completion.
|
||||||
@@ -357,7 +357,7 @@ class PostponedArgumentInputTypesResolver(
|
|||||||
*
|
*
|
||||||
* TODO: investigate why we can't do it for anonymous functions in full mode always (see `diagnostics/tests/resolve/resolveWithSpecifiedFunctionLiteralWithId.kt`)
|
* TODO: investigate why we can't do it for anonymous functions in full mode always (see `diagnostics/tests/resolve/resolveWithSpecifiedFunctionLiteralWithId.kt`)
|
||||||
*/
|
*/
|
||||||
if (completionMode == KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode.PARTIAL && !isAnonymousFunction(argument))
|
if (completionMode == ConstraintSystemCompletionMode.PARTIAL && !isAnonymousFunction(argument))
|
||||||
return@any false
|
return@any false
|
||||||
if (argument.revisedExpectedType != null) return@any false
|
if (argument.revisedExpectedType != null) return@any false
|
||||||
val parameterTypesInfo =
|
val parameterTypesInfo =
|
||||||
@@ -459,7 +459,7 @@ class PostponedArgumentInputTypesResolver(
|
|||||||
val relatedVariables = type.getPureArgumentsForFunctionalTypeOrSubtype()
|
val relatedVariables = type.getPureArgumentsForFunctionalTypeOrSubtype()
|
||||||
.flatMap { getAllDeeplyRelatedTypeVariables(it, dependencyProvider) }
|
.flatMap { getAllDeeplyRelatedTypeVariables(it, dependencyProvider) }
|
||||||
val variableForFixation = variableFixationFinder.findFirstVariableForFixation(
|
val variableForFixation = variableFixationFinder.findFirstVariableForFixation(
|
||||||
this, relatedVariables, postponedArguments, KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode.FULL, topLevelType
|
this, relatedVariables, postponedArguments, ConstraintSystemCompletionMode.FULL, topLevelType
|
||||||
)
|
)
|
||||||
|
|
||||||
if (variableForFixation == null || !variableForFixation.hasProperConstraint)
|
if (variableForFixation == null || !variableForFixation.hasProperConstraint)
|
||||||
|
|||||||
+1
-2
@@ -16,8 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.resolve.calls.inference.components
|
package org.jetbrains.kotlin.resolve.calls.inference.components
|
||||||
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode
|
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode.PARTIAL
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode.PARTIAL
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.Constraint
|
import org.jetbrains.kotlin.resolve.calls.inference.model.Constraint
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.DeclaredUpperBoundConstraintPosition
|
import org.jetbrains.kotlin.resolve.calls.inference.model.DeclaredUpperBoundConstraintPosition
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.VariableWithConstraints
|
import org.jetbrains.kotlin.resolve.calls.inference.model.VariableWithConstraints
|
||||||
|
|||||||
+2
-5
@@ -7,10 +7,7 @@ package org.jetbrains.kotlin.resolve.calls.inference.model
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzer
|
import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzer
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.*
|
import org.jetbrains.kotlin.resolve.calls.inference.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintInjector
|
import org.jetbrains.kotlin.resolve.calls.inference.components.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.PostponedArgumentInputTypesResolver
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ResultTypeResolver
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedAtom
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedAtom
|
||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.*
|
||||||
import org.jetbrains.kotlin.types.checker.NewKotlinTypeChecker
|
import org.jetbrains.kotlin.types.checker.NewKotlinTypeChecker
|
||||||
@@ -30,7 +27,7 @@ class NewConstraintSystemImpl(
|
|||||||
ConstraintSystemBuilder,
|
ConstraintSystemBuilder,
|
||||||
ConstraintInjector.Context,
|
ConstraintInjector.Context,
|
||||||
ResultTypeResolver.Context,
|
ResultTypeResolver.Context,
|
||||||
KotlinConstraintSystemCompleter.Context,
|
ConstraintSystemCompletionContext,
|
||||||
PostponedArgumentInputTypesResolver.Context,
|
PostponedArgumentInputTypesResolver.Context,
|
||||||
PostponedArgumentsAnalyzer.Context {
|
PostponedArgumentsAnalyzer.Context {
|
||||||
private val storage = MutableConstraintStorage()
|
private val storage = MutableConstraintStorage()
|
||||||
|
|||||||
Reference in New Issue
Block a user