Inference. Remove chain inference stubs from fixed variables constraints
This commit is contained in:
+4
-4
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.types.TypeApproximatorConfiguration
|
|||||||
import org.jetbrains.kotlin.types.model.*
|
import org.jetbrains.kotlin.types.model.*
|
||||||
import org.jetbrains.kotlin.utils.SmartList
|
import org.jetbrains.kotlin.utils.SmartList
|
||||||
import org.jetbrains.kotlin.utils.SmartSet
|
import org.jetbrains.kotlin.utils.SmartSet
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
// todo problem: intersection types in constrains: A <: Number, B <: Inv<A & Any> =>? B <: Inv<out Number & Any>
|
// todo problem: intersection types in constrains: A <: Number, B <: Inv<A & Any> =>? B <: Inv<out Number & Any>
|
||||||
@@ -53,7 +52,7 @@ class ConstraintIncorporator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun Context.areThereRecursiveConstraints(typeVariable: TypeVariableMarker, constraint: Constraint) =
|
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
|
// A <:(=) \alpha <:(=) B => A <: B
|
||||||
private fun Context.directWithVariable(
|
private fun Context.directWithVariable(
|
||||||
@@ -259,8 +258,9 @@ class ConstraintIncorporator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun Context.getNestedTypeVariables(type: KotlinTypeMarker): List<TypeVariableMarker> =
|
private fun Context.getNestedTypeVariables(type: KotlinTypeMarker): List<TypeVariableMarker> =
|
||||||
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 {
|
private fun KotlinTypeMarker.substitute(c: Context, typeVariable: TypeVariableMarker, value: KotlinTypeMarker): KotlinTypeMarker {
|
||||||
val substitutor = c.typeSubstitutorByTypeConstructor(mapOf(typeVariable.freshTypeConstructor(c) to value))
|
val substitutor = c.typeSubstitutorByTypeConstructor(mapOf(typeVariable.freshTypeConstructor(c) to value))
|
||||||
|
|||||||
+2
-2
@@ -207,11 +207,11 @@ fun TypeSystemInferenceExtensionContext.extractProjectionsForAllCapturedTypes(ba
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun TypeSystemInferenceExtensionContext.containsTypeVariable(type: KotlinTypeMarker, typeVariable: TypeConstructorMarker): Boolean {
|
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)
|
val typeProjections = extractProjectionsForAllCapturedTypes(type)
|
||||||
|
|
||||||
return typeProjections.any { typeProjectionsType ->
|
return typeProjections.any { typeProjectionsType ->
|
||||||
typeProjectionsType.contains { it.typeConstructor() == typeVariable }
|
typeProjectionsType.contains { it.typeConstructor().unwrapStubTypeVariableConstructor() == typeVariable }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user