Put not-null original type as last possible smart cast target

This fixes muted tests testSmartCast (IDE highlighting) and
testNestedSealed (Diagnostics).
Together with commit 555b3f12 this makes #KT-15901 Fixed
This commit is contained in:
Mikhail Glukhikh
2017-03-22 20:33:37 +03:00
parent 1cb4580380
commit 1780f7c9a2
6 changed files with 32 additions and 10 deletions
@@ -46,6 +46,7 @@ interface DataFlowInfo {
*
* IMPORTANT: by default, the original (native) type for this value
* are NOT included. So it's quite possible to get an empty set here.
* Also, type order in the result set MAKES SENSE so keep it stable and do not change without reason
*/
fun getCollectedTypes(key: DataFlowValue): Set<KotlinType>
@@ -55,6 +56,7 @@ interface DataFlowInfo {
*
* IMPORTANT: by default, the original (native) type for this value
* are NOT included. So it's quite possible to get an empty set here.
* Also, type order in the result set MAKES SENSE so keep it stable and do not change without reason
*/
fun getStableTypes(key: DataFlowValue): Set<KotlinType>
@@ -122,12 +122,12 @@ internal class DelegatingDataFlowInfo private constructor(
val enrichedTypes = newLinkedHashSetWithExpectedSize<KotlinType>(types.size + 1)
val originalType = key.type
if (originalType.isMarkedNullable) {
enrichedTypes.add(TypeUtils.makeNotNullable(originalType))
}
for (type in types) {
enrichedTypes.add(TypeUtils.makeNotNullable(type))
}
if (originalType.isMarkedNullable) {
enrichedTypes.add(TypeUtils.makeNotNullable(originalType))
}
return enrichedTypes
}