diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.java index 869943be3b6..a6c1dd88f32 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.java @@ -140,13 +140,18 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL @Override @NotNull public Set getPossibleTypes(@NotNull DataFlowValue key) { - KotlinType originalType = key.getType(); + return getPossibleTypes(key, true); + } + + @NotNull + private Set getPossibleTypes(@NotNull DataFlowValue key, boolean enrichWithNotNull) { Set types = collectTypesFromMeAndParents(key); - if (getNullability(key).canBeNull()) { + if (!enrichWithNotNull || getNullability(key).canBeNull()) { return types; } Set enrichedTypes = Sets.newHashSetWithExpectedSize(types.size() + 1); + KotlinType originalType = key.getType(); if (originalType.isMarkedNullable()) { enrichedTypes.add(TypeUtils.makeNotNullable(originalType)); } @@ -160,10 +165,15 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL @Override @NotNull public Set getPredictableTypes(@NotNull DataFlowValue key) { + return getPredictableTypes(key, true); + } + + @NotNull + private Set getPredictableTypes(@NotNull DataFlowValue key, boolean enrichWithNotNull) { if (!key.isPredictable()) { return new LinkedHashSet(); } - return getPossibleTypes(key); + return getPossibleTypes(key, enrichWithNotNull); } /** @@ -222,8 +232,8 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL changed |= putNullability(builder, b, nullabilityOfB.refine(nullabilityOfA)); SetMultimap newTypeInfo = newTypeInfo(); - newTypeInfo.putAll(a, getPredictableTypes(b)); - newTypeInfo.putAll(b, getPredictableTypes(a)); + newTypeInfo.putAll(a, getPredictableTypes(b, false)); + newTypeInfo.putAll(b, getPredictableTypes(a, false)); if (!a.getType().equals(b.getType())) { // To avoid recording base types of own type if (!TypeUtilsKt.isSubtypeOf(a.getType(), b.getType())) {