[FE] Check types in canHaveCommonSubtype for intersection emptiness with erasing nullability

It doesn't affect having common subtypes check but may lead to false positives

^KT-52364 Fixed
This commit is contained in:
Victor Petukhov
2022-05-12 14:57:21 +02:00
committed by teamcity
parent ba158de848
commit 11eb5ce39c
7 changed files with 68 additions and 4 deletions
@@ -392,10 +392,10 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui
"One of the passed type should be an interface"
}
@Suppress("NAME_SHADOWING")
val firstType = firstType.withNullability(false).eraseContainingTypeParameters()
val firstType = firstType.eraseContainingTypeParameters()
@Suppress("NAME_SHADOWING")
val secondType = secondType.withNullability(false).eraseContainingTypeParameters()
val secondType = secondType.eraseContainingTypeParameters()
// interface A<K>
// interface B: A<String>
@@ -414,14 +414,14 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui
val typeCheckerState = newTypeCheckerState(errorTypesEqualToAnything = true, stubTypesEqualToAnything = true)
for (i in expandedTypes.indices) {
val firstType = expandedTypes[i]
val firstType = expandedTypes[i].withNullability(false)
val firstTypeConstructor = firstType.typeConstructor()
if (!firstType.mayCauseEmptyIntersection())
continue
for (j in i + 1 until expandedTypes.size) {
val secondType = expandedTypes[j]
val secondType = expandedTypes[j].withNullability(false)
val secondTypeConstructor = secondType.typeConstructor()
if (!secondType.mayCauseEmptyIntersection())