Rewrite DelegatingDataFlowInfo using immutable collections from javaslang
It may be useful because data-flow info is mostly the same for neighbouring expressions and changes between them should be minor. Thus, it should help to avoid making copies of huge maps and reusing them instead
This commit is contained in:
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.idea.util.getImplicitReceiversWithInstance
|
||||
import org.jetbrains.kotlin.idea.util.getResolutionScope
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoAfter
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoBefore
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
@@ -35,6 +34,8 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||
import org.jetbrains.kotlin.util.javaslang.component1
|
||||
import org.jetbrains.kotlin.util.javaslang.component2
|
||||
import java.util.*
|
||||
|
||||
class SmartCastCalculator(
|
||||
@@ -119,10 +120,10 @@ class SmartCastCalculator(
|
||||
|
||||
val entityToInfo = HashMap<Any, SmartCastInfo>()
|
||||
|
||||
for ((dataFlowValue, types) in dataFlowInfo.completeTypeInfo.asMap().entries) {
|
||||
for ((dataFlowValue, types) in dataFlowInfo.completeTypeInfo) {
|
||||
val entity = dataFlowValueToEntity.invoke(dataFlowValue)
|
||||
if (entity != null) {
|
||||
entityToInfo[entity] = SmartCastInfo(types, false)
|
||||
entityToInfo[entity] = SmartCastInfo(types.toJavaList(), false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,4 +142,4 @@ class SmartCastCalculator(
|
||||
val type = classifier.defaultType
|
||||
return getImplicitReceiversWithInstance().firstOrNull { it.type.isSubtypeOf(type) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user