[Minor] Rename fresh variable substitutor in resolved atom
This commit is contained in:
+1
-3
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.resolve.calls.inference.NewConstraintSystem
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.addSubtypeConstraintIfCompatible
|
||||
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.model.Constraint
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage.Empty.hasContradiction
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ExpectedTypeConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
@@ -20,7 +19,6 @@ import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.types.model.TypeSystemInferenceExtensionContext
|
||||
import org.jetbrains.kotlin.types.model.defaultType
|
||||
import org.jetbrains.kotlin.types.model.isIntegerLiteralTypeConstructor
|
||||
import org.jetbrains.kotlin.types.model.typeConstructor
|
||||
import org.jetbrains.kotlin.types.typeUtil.contains
|
||||
@@ -147,7 +145,7 @@ class KotlinCallCompleter(
|
||||
|
||||
private fun KotlinResolutionCandidate.substitutedReturnType(): UnwrappedType? {
|
||||
val returnType = resolvedCall.candidateDescriptor.returnType?.unwrap() ?: return null
|
||||
return resolvedCall.substitutor.safeSubstitute(returnType)
|
||||
return resolvedCall.freshVariablesSubstitutor.safeSubstitute(returnType)
|
||||
}
|
||||
|
||||
private fun KotlinResolutionCandidate.addExpectedTypeConstraint(
|
||||
|
||||
+5
-5
@@ -125,11 +125,11 @@ internal object NoArguments : ResolutionPart() {
|
||||
internal object CreateFreshVariablesSubstitutor : ResolutionPart() {
|
||||
override fun KotlinResolutionCandidate.process(workIndex: Int) {
|
||||
if (candidateDescriptor.typeParameters.isEmpty()) {
|
||||
resolvedCall.substitutor = FreshVariableNewTypeSubstitutor.Empty
|
||||
resolvedCall.freshVariablesSubstitutor = FreshVariableNewTypeSubstitutor.Empty
|
||||
return
|
||||
}
|
||||
val toFreshVariables = createToFreshVariableSubstitutorAndAddInitialConstraints(candidateDescriptor, csBuilder)
|
||||
resolvedCall.substitutor = toFreshVariables
|
||||
resolvedCall.freshVariablesSubstitutor = toFreshVariables
|
||||
|
||||
// bad function -- error on declaration side
|
||||
if (csBuilder.hasContradiction) return
|
||||
@@ -232,7 +232,7 @@ internal object PostponedVariablesInitializerResolutionPart : ResolutionPart() {
|
||||
if (!callComponents.statelessCallbacks.isCoroutineCall(argument, parameter)) continue
|
||||
val receiverType = parameter.type.getReceiverTypeFromFunctionType() ?: continue
|
||||
|
||||
for (freshVariable in resolvedCall.substitutor.freshVariables) {
|
||||
for (freshVariable in resolvedCall.freshVariablesSubstitutor.freshVariables) {
|
||||
if (resolvedCall.typeArgumentMappingByOriginal.getTypeArgument(freshVariable.originalTypeParameter) is SimpleTypeArgument)
|
||||
continue
|
||||
|
||||
@@ -284,7 +284,7 @@ private fun KotlinResolutionCandidate.prepareExpectedType(
|
||||
callComponents.languageVersionSettings
|
||||
)
|
||||
val resultType = knownTypeParametersResultingSubstitutor?.substitute(argumentType) ?: argumentType
|
||||
return resolvedCall.substitutor.safeSubstitute(resultType)
|
||||
return resolvedCall.freshVariablesSubstitutor.safeSubstitute(resultType)
|
||||
}
|
||||
|
||||
private fun KotlinResolutionCandidate.getExpectedTypeWithSAMConversion(
|
||||
@@ -414,7 +414,7 @@ internal object ErrorDescriptorResolutionPart : ResolutionPart() {
|
||||
}
|
||||
resolvedCall.typeArgumentMappingByOriginal = TypeArgumentsToParametersMapper.TypeArgumentsMapping.NoExplicitArguments
|
||||
resolvedCall.argumentMappingByOriginal = emptyMap()
|
||||
resolvedCall.substitutor = FreshVariableNewTypeSubstitutor.Empty
|
||||
resolvedCall.freshVariablesSubstitutor = FreshVariableNewTypeSubstitutor.Empty
|
||||
resolvedCall.argumentToCandidateParameter = emptyMap()
|
||||
|
||||
kotlinCall.explicitReceiver?.safeAs<SimpleKotlinCallArgument>()?.let {
|
||||
|
||||
+2
-2
@@ -166,7 +166,7 @@ class KotlinConstraintSystemCompleter(
|
||||
|
||||
fun ResolvedAtom.process(to: LinkedHashSet<TypeConstructor>) {
|
||||
val typeVariables = when (this) {
|
||||
is ResolvedCallAtom -> substitutor.freshVariables
|
||||
is ResolvedCallAtom -> freshVariablesSubstitutor.freshVariables
|
||||
is ResolvedCallableReferenceAtom -> candidate?.freshSubstitutor?.freshVariables.orEmpty()
|
||||
is ResolvedLambdaAtom -> listOfNotNull(typeVariableForLambdaReturnType)
|
||||
else -> emptyList()
|
||||
@@ -247,7 +247,7 @@ class KotlinConstraintSystemCompleter(
|
||||
private fun findResolvedAtomBy(typeVariable: TypeVariableMarker, topLevelAtoms: List<ResolvedAtom>): ResolvedAtom? {
|
||||
fun ResolvedAtom.check(): ResolvedAtom? {
|
||||
val suitableCall = when (this) {
|
||||
is ResolvedCallAtom -> typeVariable in substitutor.freshVariables
|
||||
is ResolvedCallAtom -> typeVariable in freshVariablesSubstitutor.freshVariables
|
||||
is ResolvedCallableReferenceAtom -> candidate?.freshSubstitutor?.freshVariables?.let { typeVariable in it } ?: false
|
||||
is ResolvedLambdaAtom -> typeVariable == typeVariableForLambdaReturnType
|
||||
else -> false
|
||||
|
||||
@@ -63,7 +63,7 @@ abstract class ResolvedCallAtom : ResolvedAtom() {
|
||||
abstract val extensionReceiverArgument: SimpleKotlinCallArgument?
|
||||
abstract val typeArgumentMappingByOriginal: TypeArgumentsToParametersMapper.TypeArgumentsMapping
|
||||
abstract val argumentMappingByOriginal: Map<ValueParameterDescriptor, ResolvedCallArgument>
|
||||
abstract val substitutor: FreshVariableNewTypeSubstitutor
|
||||
abstract val freshVariablesSubstitutor: FreshVariableNewTypeSubstitutor
|
||||
|
||||
abstract val argumentsWithConversion: Map<KotlinCallArgument, SamConversionDescription>
|
||||
}
|
||||
@@ -237,7 +237,7 @@ fun CallResolutionResult.resultCallAtom(): ResolvedCallAtom? =
|
||||
val ResolvedCallAtom.freshReturnType: UnwrappedType?
|
||||
get() {
|
||||
val returnType = candidateDescriptor.returnType ?: return null
|
||||
return substitutor.safeSubstitute(returnType.unwrap())
|
||||
return freshVariablesSubstitutor.safeSubstitute(returnType.unwrap())
|
||||
}
|
||||
|
||||
class PartialCallContainer(val result: PartialCallResolutionResult?) {
|
||||
|
||||
+1
-1
@@ -178,7 +178,7 @@ class MutableResolvedCallAtom(
|
||||
) : ResolvedCallAtom() {
|
||||
override lateinit var typeArgumentMappingByOriginal: TypeArgumentsToParametersMapper.TypeArgumentsMapping
|
||||
override lateinit var argumentMappingByOriginal: Map<ValueParameterDescriptor, ResolvedCallArgument>
|
||||
override lateinit var substitutor: FreshVariableNewTypeSubstitutor
|
||||
override lateinit var freshVariablesSubstitutor: FreshVariableNewTypeSubstitutor
|
||||
lateinit var argumentToCandidateParameter: Map<KotlinCallArgument, ValueParameterDescriptor>
|
||||
private var samAdapterMap: HashMap<KotlinCallArgument, SamConversionDescription>? = null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user