From d024d2e64c2168b82d41d52a9cc92be14af6fce6 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Mon, 6 Aug 2018 17:31:51 +0700 Subject: [PATCH] Adjust PreliminaryLoopVisitor to new contracts of DataFlowInfo Previously, there was a contract that if it contains some non-trivial type info it also has it in `completeNullabilityInfo`. But after two previous changes it became false --- .../kotlin/types/expressions/PreliminaryLoopVisitor.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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) {