Reuse built functional types for postponed arguments by expected types and paths from a top level type variable
^KT-42221 Fixed
This commit is contained in:
@@ -7,6 +7,8 @@ package org.jetbrains.kotlin.types.model
|
||||
|
||||
import org.jetbrains.kotlin.types.AbstractTypeCheckerContext
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
|
||||
@@ -207,6 +209,25 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui
|
||||
fun getFunctionTypeConstructor(parametersNumber: Int, isSuspend: Boolean): TypeConstructorMarker
|
||||
|
||||
fun getKFunctionTypeConstructor(parametersNumber: Int, isSuspend: Boolean): TypeConstructorMarker
|
||||
|
||||
private fun KotlinTypeMarker.extractTypeVariables(to: MutableSet<TypeVariableTypeConstructorMarker>) {
|
||||
for (i in 0 until argumentsCount()) {
|
||||
val argument = getArgument(i)
|
||||
|
||||
if (argument.isStarProjection()) continue
|
||||
|
||||
val argumentType = argument.getType()
|
||||
val argumentTypeConstructor = argumentType.typeConstructor()
|
||||
if (argumentTypeConstructor is TypeVariableTypeConstructorMarker) {
|
||||
to.add(argumentTypeConstructor)
|
||||
} else if (argumentType.argumentsCount() != 0) {
|
||||
argumentType.extractTypeVariables(to)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
fun KotlinTypeMarker.extractTypeVariables() = buildSet { extractTypeVariables(this) }
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user