[NI] Fix reporting smartcast diagnostics for intersection types

#KT-30826 Fixed
This commit is contained in:
Dmitriy Novozhilov
2019-04-08 12:37:56 +03:00
parent ece3a0fe90
commit 18f9272f56
15 changed files with 115 additions and 36 deletions
@@ -243,3 +243,12 @@ val TypeParameterDescriptor.representativeUpperBound: KotlinType
} ?: upperBounds.first()
}
fun KotlinType.expandIntersectionTypeIfNecessary(): Collection<KotlinType> {
if (constructor !is IntersectionTypeConstructor) return listOf(this)
val types = constructor.supertypes
return if (isMarkedNullable) {
types.map { it.makeNullable() }
} else {
types
}
}