Don't do new captured type specific checks for old ones in the type checker

^KT-47143 Fixed
This commit is contained in:
Victor Petukhov
2021-06-08 14:22:39 +03:00
parent 02a56a3077
commit 1b82227308
11 changed files with 62 additions and 2 deletions
@@ -376,8 +376,9 @@ object AbstractTypeChecker {
): Boolean {
val simpleSubArgumentType = subArgumentType.asSimpleType()
if (simpleSubArgumentType !is CapturedTypeMarker || !simpleSubArgumentType.typeConstructor().projection().isStarProjection())
return false
if (simpleSubArgumentType !is CapturedTypeMarker || simpleSubArgumentType.isOldCapturedType()
|| !simpleSubArgumentType.typeConstructor().projection().isStarProjection()
) return false
// Only 'for subtyping' captured types are approximated before adding constraints (see ConstraintInjector.addNewIncorporatedConstraint)
// that can lead to adding problematic constraints like UPPER(Nothing) given by CapturedType(*) <: TypeVariable(A)
if (simpleSubArgumentType.captureStatus() != CaptureStatus.FOR_SUBTYPING) return false
@@ -285,6 +285,7 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
fun SimpleTypeMarker.typeConstructor(): TypeConstructorMarker
fun KotlinTypeMarker.withNullability(nullable: Boolean): KotlinTypeMarker
fun CapturedTypeMarker.isOldCapturedType(): Boolean
fun CapturedTypeMarker.typeConstructor(): CapturedTypeConstructorMarker
fun CapturedTypeMarker.captureStatus(): CaptureStatus
fun CapturedTypeMarker.isProjectionNotNull(): Boolean