FIR: Add fast-path for getOrderedAllTypeVariables if no synthetics

This commit is contained in:
Simon Ogorodnik
2021-12-13 13:20:32 +03:00
committed by teamcity
parent 8cf97127fe
commit 32a80bf38e
4 changed files with 10 additions and 1 deletions
@@ -391,7 +391,9 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents, p
topLevel.collectAllTypeVariables()
}
result.addAll(c.notFixedTypeVariables.filter { context.inferenceSession.isSyntheticTypeVariable(it.value.typeVariable) }.keys.asIterable())
if (context.inferenceSession.hasSyntheticTypeVariables()) {
result.addAll(c.notFixedTypeVariables.filter { context.inferenceSession.isSyntheticTypeVariable(it.value.typeVariable) }.keys.asIterable())
}
require(result.size == c.notFixedTypeVariables.size) {
val notFoundTypeVariables = c.notFixedTypeVariables.keys.toMutableSet().apply { removeAll(result) }
@@ -41,6 +41,8 @@ class FirBuilderInferenceSession(
override val currentConstraintStorage: ConstraintStorage
get() = ConstraintStorage.Empty
override fun hasSyntheticTypeVariables(): Boolean = false
override fun isSyntheticTypeVariable(typeVariable: TypeVariableMarker): Boolean {
return false
}
@@ -144,6 +144,9 @@ class FirDelegatedPropertyInferenceSession(
return typeContext.typeSubstitutorByTypeConstructor(bindings)
}
override fun hasSyntheticTypeVariables(): Boolean {
return syntheticTypeVariableByTypeVariable.isNotEmpty()
}
override fun isSyntheticTypeVariable(typeVariable: TypeVariableMarker): Boolean {
return typeVariable in syntheticTypeVariableByTypeVariable.values
@@ -32,6 +32,7 @@ abstract class FirInferenceSession {
abstract fun registerStubTypes(map: Map<TypeVariableMarker, StubTypeMarker>)
abstract fun hasSyntheticTypeVariables(): Boolean
abstract fun isSyntheticTypeVariable(typeVariable: TypeVariableMarker): Boolean
abstract fun fixSyntheticTypeVariableWithNotEnoughInformation(
typeVariable: TypeVariableMarker,
@@ -66,6 +67,7 @@ abstract class FirStubInferenceSession : FirInferenceSession() {
override fun registerStubTypes(map: Map<TypeVariableMarker, StubTypeMarker>) {}
override fun hasSyntheticTypeVariables(): Boolean = false
override fun isSyntheticTypeVariable(typeVariable: TypeVariableMarker): Boolean = false
override fun fixSyntheticTypeVariableWithNotEnoughInformation(
typeVariable: TypeVariableMarker,