[NI] Improve type inference for T vs Captured(in Smt)
If we has Inv<T> <: Inv<Captured(in Foo)> then we should get: - T <: Captured(in Foo) - Captured(in Foo) <: T Before this commit we got: T <: Foo instead first constraint.
This commit is contained in:
committed by
Mikhail Zarechenskiy
parent
91241a34d1
commit
915ac32bfb
+5
-2
@@ -29,8 +29,11 @@ abstract class TypeCheckerContextForConstraintSystem : TypeCheckerContext(errorT
|
||||
abstract fun addUpperConstraint(typeVariable: TypeConstructor, superType: UnwrappedType)
|
||||
abstract fun addLowerConstraint(typeVariable: TypeConstructor, subType: UnwrappedType)
|
||||
|
||||
override fun shouldCheckOnlyLowerBoundForCapturedType(subType: SimpleType, superType: NewCapturedType) =
|
||||
subType.contains { it.anyBound(this::isMyTypeVariable) }
|
||||
override fun getLowerCapturedTypePolicy(subType: SimpleType, superType: NewCapturedType) = when {
|
||||
isMyTypeVariable(subType) -> LowerCapturedTypePolicy.SKIP_LOWER
|
||||
subType.contains { it.anyBound(this::isMyTypeVariable) } -> LowerCapturedTypePolicy.CHECK_ONLY_LOWER
|
||||
else -> LowerCapturedTypePolicy.CHECK_SUBTYPE_AND_LOWER
|
||||
}
|
||||
|
||||
/**
|
||||
* todo: possible we should override this method, because otherwise OR in subtyping transformed to AND in constraint system
|
||||
|
||||
Reference in New Issue
Block a user