Deduct x != null from x?.y is NotNullType
This commit is contained in:
+5
-1
@@ -231,9 +231,13 @@ internal class DelegatingDataFlowInfo private constructor(
|
|||||||
if (value.type == type) return this
|
if (value.type == type) return this
|
||||||
if (getCollectedTypes(value).contains(type)) return this
|
if (getCollectedTypes(value).contains(type)) return this
|
||||||
if (!value.type.isFlexible() && value.type.isSubtypeOf(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()
|
val newTypeInfo = newTypeInfo()
|
||||||
newTypeInfo.put(value, type)
|
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)
|
return create(this, newNullabilityInfo, newTypeInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -52,8 +52,7 @@ fun kt4565_1(a: SomeClass?) {
|
|||||||
<!DEBUG_INFO_SMARTCAST!>a<!>.data.hashCode()
|
<!DEBUG_INFO_SMARTCAST!>a<!>.data.hashCode()
|
||||||
}
|
}
|
||||||
if (a?.data is String) {
|
if (a?.data is String) {
|
||||||
// To be supported
|
<!DEBUG_INFO_SMARTCAST!>a<!>.data.<!UNRESOLVED_REFERENCE!>length<!>
|
||||||
a<!UNSAFE_CALL!>.<!>data.<!UNRESOLVED_REFERENCE!>length<!>
|
|
||||||
data.<!UNRESOLVED_REFERENCE!>length<!>
|
data.<!UNRESOLVED_REFERENCE!>length<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user