[NI] Add constraint K <: T from constraint K <: CapturedType(in T)

#KT-33263 Fixed
This commit is contained in:
Dmitriy Novozhilov
2019-12-23 17:10:20 +03:00
parent b54169d312
commit 51424ec598
7 changed files with 104 additions and 4 deletions
@@ -28,10 +28,20 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck
abstract fun addLowerConstraint(typeVariable: TypeConstructorMarker, subType: KotlinTypeMarker)
override fun getLowerCapturedTypePolicy(subType: SimpleTypeMarker, superType: CapturedTypeMarker): LowerCapturedTypePolicy = when {
isMyTypeVariable(subType) -> LowerCapturedTypePolicy.SKIP_LOWER
subType.contains { it.anyBound(this::isMyTypeVariable) } -> LowerCapturedTypePolicy.CHECK_ONLY_LOWER
else -> LowerCapturedTypePolicy.CHECK_SUBTYPE_AND_LOWER
override fun getLowerCapturedTypePolicy(subType: SimpleTypeMarker, superType: CapturedTypeMarker): LowerCapturedTypePolicy {
return when {
isMyTypeVariable(subType) -> {
val projection = superType.typeConstructorProjection()
val type = projection.getType().asSimpleType()
if (projection.getVariance() == TypeVariance.IN && type != null && isMyTypeVariable(type)) {
LowerCapturedTypePolicy.CHECK_ONLY_LOWER
} else {
LowerCapturedTypePolicy.SKIP_LOWER
}
}
subType.contains { it.anyBound(this::isMyTypeVariable) } -> LowerCapturedTypePolicy.CHECK_ONLY_LOWER
else -> LowerCapturedTypePolicy.CHECK_SUBTYPE_AND_LOWER
}
}
/**