[FIR] Add DeclaredUpperBoundConstraintPosition to Fir
This commit is contained in:
committed by
Mikhail Glukhikh
parent
d3670d4f5f
commit
7245475196
+2
-1
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.symbols.invoke
|
|||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.impl.FirTypePlaceholderProjection
|
import org.jetbrains.kotlin.fir.types.impl.FirTypePlaceholderProjection
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation
|
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.inference.model.FirDeclaredUpperBoundConstraintPosition
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
|
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
|
||||||
|
|
||||||
|
|
||||||
@@ -102,7 +103,7 @@ fun createToFreshVariableSubstitutorAndAddInitialConstraints(
|
|||||||
upperBound: ConeKotlinType//,
|
upperBound: ConeKotlinType//,
|
||||||
//position: DeclaredUpperBoundConstraintPosition
|
//position: DeclaredUpperBoundConstraintPosition
|
||||||
) {
|
) {
|
||||||
csBuilder.addSubtypeConstraint(defaultType, toFreshVariables.substituteOrSelf(upperBound), SimpleConstraintSystemConstraintPosition)
|
csBuilder.addSubtypeConstraint(defaultType, toFreshVariables.substituteOrSelf(upperBound), FirDeclaredUpperBoundConstraintPosition())
|
||||||
}
|
}
|
||||||
|
|
||||||
for (index in typeParameters.indices) {
|
for (index in typeParameters.indices) {
|
||||||
|
|||||||
+3
-6
@@ -13,10 +13,7 @@ import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
|
|||||||
import org.jetbrains.kotlin.resolve.calls.components.TypeArgumentsToParametersMapper.TypeArgumentsMapping.NoExplicitArguments
|
import org.jetbrains.kotlin.resolve.calls.components.TypeArgumentsToParametersMapper.TypeArgumentsMapping.NoExplicitArguments
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation
|
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.FreshVariableNewTypeSubstitutor
|
import org.jetbrains.kotlin.resolve.calls.inference.components.FreshVariableNewTypeSubstitutor
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.DeclaredUpperBoundConstraintPosition
|
import org.jetbrains.kotlin.resolve.calls.inference.model.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ExplicitTypeParameterConstraintPosition
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.KnownTypeParameterConstraintPosition
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableFromCallableDescriptor
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.substitute
|
import org.jetbrains.kotlin.resolve.calls.inference.substitute
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.getReceiverValueWithSmartCast
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.getReceiverValueWithSmartCast
|
||||||
@@ -197,7 +194,7 @@ internal object CreateFreshVariablesSubstitutor : ResolutionPart() {
|
|||||||
for (index in typeParameters.indices) {
|
for (index in typeParameters.indices) {
|
||||||
val typeParameter = typeParameters[index]
|
val typeParameter = typeParameters[index]
|
||||||
val freshVariable = freshTypeVariables[index]
|
val freshVariable = freshTypeVariables[index]
|
||||||
val position = DeclaredUpperBoundConstraintPosition(typeParameter)
|
val position = DeclaredUpperBoundConstraintPositionImpl(typeParameter)
|
||||||
|
|
||||||
for (upperBound in typeParameter.upperBounds) {
|
for (upperBound in typeParameter.upperBounds) {
|
||||||
freshVariable.addSubtypeConstraint(upperBound, position)
|
freshVariable.addSubtypeConstraint(upperBound, position)
|
||||||
@@ -218,7 +215,7 @@ internal object CreateFreshVariablesSubstitutor : ResolutionPart() {
|
|||||||
// there can be null in case we already captured type parameter in outer class (in case of inner classes)
|
// there can be null in case we already captured type parameter in outer class (in case of inner classes)
|
||||||
// see test innerClassTypeAliasConstructor.kt
|
// see test innerClassTypeAliasConstructor.kt
|
||||||
val originalTypeParameter = originalTypeParameters.getOrNull(originalIndex) ?: continue
|
val originalTypeParameter = originalTypeParameters.getOrNull(originalIndex) ?: continue
|
||||||
val position = DeclaredUpperBoundConstraintPosition(originalTypeParameter)
|
val position = DeclaredUpperBoundConstraintPositionImpl(originalTypeParameter)
|
||||||
for (upperBound in originalTypeParameter.upperBounds) {
|
for (upperBound in originalTypeParameter.upperBounds) {
|
||||||
freshVariable.addSubtypeConstraint(upperBound, position)
|
freshVariable.addSubtypeConstraint(upperBound, position)
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -37,10 +37,14 @@ class ExpectedTypeConstraintPosition(val topLevelCall: KotlinCall) : ConstraintP
|
|||||||
override fun toString() = "ExpectedType for call $topLevelCall"
|
override fun toString() = "ExpectedType for call $topLevelCall"
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeclaredUpperBoundConstraintPosition(val typeParameterDescriptor: TypeParameterDescriptor) : ConstraintPosition() {
|
sealed class DeclaredUpperBoundConstraintPosition : ConstraintPosition()
|
||||||
|
|
||||||
|
class DeclaredUpperBoundConstraintPositionImpl(val typeParameterDescriptor: TypeParameterDescriptor) : DeclaredUpperBoundConstraintPosition() {
|
||||||
override fun toString() = "DeclaredUpperBound ${typeParameterDescriptor.name} from ${typeParameterDescriptor.containingDeclaration}"
|
override fun toString() = "DeclaredUpperBound ${typeParameterDescriptor.name} from ${typeParameterDescriptor.containingDeclaration}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FirDeclaredUpperBoundConstraintPosition : DeclaredUpperBoundConstraintPosition()
|
||||||
|
|
||||||
class ArgumentConstraintPosition(val argument: KotlinCallArgument) : ConstraintPosition() {
|
class ArgumentConstraintPosition(val argument: KotlinCallArgument) : ConstraintPosition() {
|
||||||
override fun toString() = "Argument $argument"
|
override fun toString() = "Argument $argument"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user