diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintIncorporator.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintIncorporator.kt index 0952a638b61..070cc9ff100 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintIncorporator.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintIncorporator.kt @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.types.TypeApproximatorConfiguration import org.jetbrains.kotlin.types.model.* import org.jetbrains.kotlin.utils.SmartList import org.jetbrains.kotlin.utils.SmartSet -import org.jetbrains.kotlin.utils.addIfNotNull import java.util.* // todo problem: intersection types in constrains: A <: Number, B <: Inv =>? B <: Inv @@ -53,7 +52,7 @@ class ConstraintIncorporator( } private fun Context.areThereRecursiveConstraints(typeVariable: TypeVariableMarker, constraint: Constraint) = - constraint.type.contains { it.typeConstructor() == typeVariable.freshTypeConstructor() } + constraint.type.contains { it.typeConstructor().unwrapStubTypeVariableConstructor() == typeVariable.freshTypeConstructor() } // A <:(=) \alpha <:(=) B => A <: B private fun Context.directWithVariable( @@ -259,8 +258,9 @@ class ConstraintIncorporator( } private fun Context.getNestedTypeVariables(type: KotlinTypeMarker): List = - getNestedArguments(type).mapNotNullTo(SmartList()) { getTypeVariable(it.getType().typeConstructor()) } - + getNestedArguments(type).mapNotNullTo(SmartList()) { + getTypeVariable(it.getType().typeConstructor().unwrapStubTypeVariableConstructor()) + } private fun KotlinTypeMarker.substitute(c: Context, typeVariable: TypeVariableMarker, value: KotlinTypeMarker): KotlinTypeMarker { val substitutor = c.typeSubstitutorByTypeConstructor(mapOf(typeVariable.freshTypeConstructor(c) to value)) diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt index 44dbc73b42c..b9e30b9884f 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt @@ -207,11 +207,11 @@ fun TypeSystemInferenceExtensionContext.extractProjectionsForAllCapturedTypes(ba } fun TypeSystemInferenceExtensionContext.containsTypeVariable(type: KotlinTypeMarker, typeVariable: TypeConstructorMarker): Boolean { - if (type.contains { it.typeConstructor() == typeVariable }) return true + if (type.contains { it.typeConstructor().unwrapStubTypeVariableConstructor() == typeVariable }) return true val typeProjections = extractProjectionsForAllCapturedTypes(type) return typeProjections.any { typeProjectionsType -> - typeProjectionsType.contains { it.typeConstructor() == typeVariable } + typeProjectionsType.contains { it.typeConstructor().unwrapStubTypeVariableConstructor() == typeVariable } } }