[FE 1.0] Fix subtyping for captured integer literal types

^KT-50877 Fixed
This commit is contained in:
Victor Petukhov
2022-01-20 12:46:46 +03:00
committed by teamcity
parent 7395f8e019
commit ec6ec20728
10 changed files with 118 additions and 1 deletions
@@ -313,8 +313,16 @@ object AbstractTypeChecker {
&& typeConstructor.supertypes().any { it.asSimpleType()?.isIntegerLiteralType() == true }
}
fun isCapturedIntegerLiteralType(type: SimpleTypeMarker): Boolean {
if (type !is CapturedTypeMarker) return false
val projection = type.typeConstructor().projection()
return !projection.isStarProjection() && projection.getType().upperBoundIfFlexible().isIntegerLiteralType()
}
fun isIntegerLiteralTypeOrCapturedOne(type: SimpleTypeMarker) = type.isIntegerLiteralType() || isCapturedIntegerLiteralType(type)
when {
subType.isIntegerLiteralType() && superType.isIntegerLiteralType() -> {
isIntegerLiteralTypeOrCapturedOne(subType) && isIntegerLiteralTypeOrCapturedOne(superType) -> {
return true
}
@@ -900,6 +900,8 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
override fun KotlinTypeMarker.isTypeVariableType(): Boolean {
return this is UnwrappedType && constructor is NewTypeVariableConstructor
}
class WA // Workaround for KT-52313
}
fun TypeVariance.convertVariance(): Variance {