[NI] Do not run "or" branches for constraint subtyping.
We should never do that, because otherwise we can get unexpected result. Example for input constraint: C(in String) <: T. If we run usual subtyping algorithm, then we get 2 constraints: C(in String) <: T and T <: String. Of course such system has contradiction.
This commit is contained in:
+6
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.inference.components
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.*
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
import org.jetbrains.kotlin.types.typeUtil.contains
|
||||
|
||||
abstract class TypeCheckerContextForConstraintSystem : TypeCheckerContext(errorTypeEqualsToAnything = true, allowedTypeVariable = false) {
|
||||
|
||||
@@ -28,6 +29,11 @@ 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 val sameConstructorPolicy get() = SeveralSupertypesWithSameConstructorPolicy.TAKE_FIRST_FOR_SUBTYPING
|
||||
|
||||
override final fun addSubtypeConstraint(subType: UnwrappedType, superType: UnwrappedType): Boolean? {
|
||||
assertInputTypes(subType, superType)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user