diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeCheckerContextForConstraintSystem.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeCheckerContextForConstraintSystem.kt index 4c2a39f80a8..7fae9e1f315 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeCheckerContextForConstraintSystem.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeCheckerContextForConstraintSystem.kt @@ -225,8 +225,8 @@ abstract class TypeCheckerContextForConstraintSystem : TypeCheckerContext(errorT with(NewKotlinTypeChecker) { this@TypeCheckerContextForConstraintSystem.isSubtypeOf(subType, superType) } private fun assertInputTypes(subType: UnwrappedType, superType: UnwrappedType) { - fun correctSubType(subType: SimpleType) = subType.isSingleClassifierType || subType.isIntersectionType || isMyTypeVariable(subType) - fun correctSuperType(superType: SimpleType) = superType.isSingleClassifierType || isMyTypeVariable(superType) + fun correctSubType(subType: SimpleType) = subType.isSingleClassifierType || subType.isIntersectionType || isMyTypeVariable(subType) || subType.isError + fun correctSuperType(superType: SimpleType) = superType.isSingleClassifierType || superType.isIntersectionType || isMyTypeVariable(superType) || superType.isError assert(subType.bothBounds(::correctSubType)) { "Not singleClassifierType and not intersection subType: $subType" diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/NewKotlinTypeChecker.kt b/core/descriptors/src/org/jetbrains/kotlin/types/checker/NewKotlinTypeChecker.kt index 60859d5d4d9..0ca16a093bb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/checker/NewKotlinTypeChecker.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/NewKotlinTypeChecker.kt @@ -121,7 +121,10 @@ object NewKotlinTypeChecker : KotlinTypeChecker { val newSubType = transformToNewType(subType) val newSuperType = transformToNewType(superType) - checkSubtypeForSpecialCases(newSubType.lowerIfFlexible(), newSuperType.upperIfFlexible())?.let { return it } + checkSubtypeForSpecialCases(newSubType.lowerIfFlexible(), newSuperType.upperIfFlexible())?.let { + addSubtypeConstraint(newSubType, newSuperType) + return it + } // we should add constraints with flexible types, otherwise we never get flexible type as answer in constraint system addSubtypeConstraint(newSubType, newSuperType)?.let { return it }