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
This commit is contained in:
Denis Zharkov
2018-08-06 17:31:51 +07:00
parent 666ca77666
commit d024d2e64c
@@ -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<DataFlowValue>().apply {
addAll(dataFlowInfo.completeNullabilityInfo.iterator().map { it._1 })
addAll(dataFlowInfo.completeTypeInfo.iterator().map { it._1 })
}
val valueSetToClear = LinkedHashSet<DataFlowValue>()
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) {