Deduct x != null from x?.y is NotNullType

This commit is contained in:
Mikhail Glukhikh
2016-07-21 20:31:19 +03:00
parent 90c6868f9b
commit 5a2f34b351
2 changed files with 6 additions and 3 deletions
@@ -231,9 +231,13 @@ internal class DelegatingDataFlowInfo private constructor(
if (value.type == type) return this
if (getCollectedTypes(value).contains(type)) return this
if (!value.type.isFlexible() && value.type.isSubtypeOf(type)) return this
val newNullabilityInfo = if (type.isMarkedNullable) EMPTY_NULLABILITY_INFO else ImmutableMap.of(value, NOT_NULL)
val newTypeInfo = newTypeInfo()
newTypeInfo.put(value, type)
val builder = Maps.newHashMap<DataFlowValue, Nullability>()
if (!type.isMarkedNullable) {
putNullability(builder, value, NOT_NULL)
}
val newNullabilityInfo = if (type.isMarkedNullable) EMPTY_NULLABILITY_INFO else ImmutableMap.copyOf(builder)
return create(this, newNullabilityInfo, newTypeInfo)
}