[NI] Fix special case of captured type handling in subtyping

Given the subtyping constraint
  X <: CapturedType(in Y)
we should check only
  X <: Y
if X contains type variables.
This commit is contained in:
Dmitry Petrov
2017-06-07 15:11:04 +03:00
committed by Mikhail Zarechenskiy
parent 26cc08be65
commit 9fa3bce73a
3 changed files with 11 additions and 9 deletions
@@ -29,8 +29,8 @@ abstract class TypeCheckerContextForConstraintSystem : TypeCheckerContext(errorT
abstract fun addUpperConstraint(typeVariable: TypeConstructor, superType: UnwrappedType)
abstract fun addLowerConstraint(typeVariable: TypeConstructor, subType: UnwrappedType)
override fun allowSubtypeViaLowerTypeForCapturedType(subType: SimpleType, superType: NewCapturedType) =
!subType.contains { it.anyBound(this::isMyTypeVariable) }
override fun shouldCheckOnlyLowerBoundForCapturedType(subType: SimpleType, superType: NewCapturedType) =
subType.contains { it.anyBound(this::isMyTypeVariable) }
/**
* todo: possible we should override this method, because otherwise OR in subtyping transformed to AND in constraint system