diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PreliminaryLoopVisitor.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PreliminaryLoopVisitor.kt index 1e6061297b9..6e788c0408c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PreliminaryLoopVisitor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PreliminaryLoopVisitor.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.types.expressions +import gnu.trove.THashSet import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor import org.jetbrains.kotlin.psi.KtLoopExpression @@ -36,9 +37,12 @@ class PreliminaryLoopVisitor private constructor() : AssignedVariablesSearcher() languageVersionSettings: LanguageVersionSettings ): DataFlowInfo { var resultFlowInfo = dataFlowInfo - val nullabilityMap = resultFlowInfo.completeNullabilityInfo + val nonTrivialValues = THashSet().apply { + addAll(dataFlowInfo.completeNullabilityInfo.iterator().map { it._1 }) + addAll(dataFlowInfo.completeTypeInfo.iterator().map { it._1 }) + } val valueSetToClear = LinkedHashSet() - for (value in nullabilityMap.keySet()) { + for (value in nonTrivialValues) { // Only stable variables are under interest here val identifierInfo = value.identifierInfo if (value.kind == DataFlowValue.Kind.STABLE_VARIABLE && identifierInfo is IdentifierInfo.Variable) {