[NI] Improve performance of resolution part for postoned variables
This commit is contained in:
+8
-14
@@ -195,22 +195,16 @@ internal object CreateFreshVariablesSubstitutor : ResolutionPart() {
|
|||||||
|
|
||||||
internal object PostponedVariablesInitializerResolutionPart : ResolutionPart() {
|
internal object PostponedVariablesInitializerResolutionPart : ResolutionPart() {
|
||||||
override fun KotlinResolutionCandidate.process(workIndex: Int) {
|
override fun KotlinResolutionCandidate.process(workIndex: Int) {
|
||||||
// smartset!
|
for ((argument, parameter) in resolvedCall.argumentToCandidateParameter) {
|
||||||
val typesForCoroutineCall = resolvedCall.argumentToCandidateParameter
|
if (!callComponents.statelessCallbacks.isCoroutineCall(argument, parameter)) continue
|
||||||
.filter { (argument, parameter) -> callComponents.statelessCallbacks.isCoroutineCall(argument, parameter) }
|
val receiverType = parameter.type.getReceiverTypeFromFunctionType() ?: continue
|
||||||
.mapNotNull { it.value.type.getReceiverTypeFromFunctionType() }
|
|
||||||
|
|
||||||
if (typesForCoroutineCall.isEmpty()) return
|
for (freshVariable in resolvedCall.substitutor.freshVariables) {
|
||||||
|
if (csBuilder.isPostponedTypeVariable(freshVariable)) continue
|
||||||
for (freshVariable in resolvedCall.substitutor.freshVariables) {
|
if (receiverType.contains { it.constructor == freshVariable.originalTypeParameter.typeConstructor }) {
|
||||||
val isPostponedVariable = typesForCoroutineCall.any { typeForCoroutineCall ->
|
csBuilder.markPostponedVariable(freshVariable)
|
||||||
typeForCoroutineCall.contains { it.constructor == freshVariable.originalTypeParameter.typeConstructor }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPostponedVariable) {
|
|
||||||
csBuilder.markPostponedVariable(freshVariable)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -38,6 +38,7 @@ interface ConstraintSystemOperation {
|
|||||||
|
|
||||||
fun isProperType(type: UnwrappedType): Boolean
|
fun isProperType(type: UnwrappedType): Boolean
|
||||||
fun isTypeVariable(type: UnwrappedType): Boolean
|
fun isTypeVariable(type: UnwrappedType): Boolean
|
||||||
|
fun isPostponedTypeVariable(typeVariable: NewTypeVariable): Boolean
|
||||||
|
|
||||||
fun getProperSuperTypeConstructors(type: UnwrappedType): List<TypeConstructor>
|
fun getProperSuperTypeConstructors(type: UnwrappedType): List<TypeConstructor>
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -188,6 +188,11 @@ class NewConstraintSystemImpl(
|
|||||||
return notFixedTypeVariables.containsKey(type.constructor)
|
return notFixedTypeVariables.containsKey(type.constructor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun isPostponedTypeVariable(typeVariable: NewTypeVariable): Boolean {
|
||||||
|
checkState(State.BUILDING, State.COMPLETION, State.TRANSACTION)
|
||||||
|
return typeVariable in postponedTypeVariables
|
||||||
|
}
|
||||||
|
|
||||||
// ConstraintInjector.Context
|
// ConstraintInjector.Context
|
||||||
override val allTypeVariables: Map<TypeConstructor, NewTypeVariable>
|
override val allTypeVariables: Map<TypeConstructor, NewTypeVariable>
|
||||||
get() {
|
get() {
|
||||||
|
|||||||
Reference in New Issue
Block a user