diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.kt index d884ff9cdf0..80112dac344 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.kt @@ -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() + 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) } diff --git a/compiler/testData/diagnostics/tests/smartCasts/safecalls/safeAccessReceiverNotNull.kt b/compiler/testData/diagnostics/tests/smartCasts/safecalls/safeAccessReceiverNotNull.kt index 04a619206a8..03d0451c7f1 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/safecalls/safeAccessReceiverNotNull.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/safecalls/safeAccessReceiverNotNull.kt @@ -52,8 +52,7 @@ fun kt4565_1(a: SomeClass?) { a.data.hashCode() } if (a?.data is String) { - // To be supported - a.data.length + a.data.length data.length } }