[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 47b1ea7fa4
commit 033d7262a2
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
}
}