From 0ff07af3ef441bc4667d8d5d818956e9f2eefe3e Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 22 Jan 2016 20:10:55 +0300 Subject: [PATCH] DelegatingDataFlowInfo: potential concurrent modification in multi map fixed --- .../resolve/calls/smartcasts/DelegatingDataFlowInfo.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 04b3dc303e3..4307f9892f4 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 @@ -297,16 +297,18 @@ internal class DelegatingDataFlowInfo private constructor( typeInfo: SetMultimap, valueWithGivenTypeInfo: DataFlowValue? = null ): DataFlowInfo { + val toDelete = newTypeInfo() for (value in typeInfo.keys()) { - var iterator = typeInfo[value].iterator() - while (iterator.hasNext()) { - val type = iterator.next() + for (type in typeInfo[value]) { // Remove original type and for not flexible type also all its supertypes (see also KT-10666) if (if (value.type.isFlexible()) value.type == type else value.type.isSubtypeOf(type)) { - iterator.remove() + toDelete.put(value, type) } } } + for ((value, type) in toDelete.entries()) { + typeInfo.remove(value, type) + } if (nullabilityInfo.isEmpty() && typeInfo.isEmpty && valueWithGivenTypeInfo == null) { return parent ?: DataFlowInfoFactory.EMPTY }