FIR: construct type with actual type arguments during GetClassCall transformation
This commit is contained in:
committed by
Mikhail Glukhikh
parent
4f8ad6bdcb
commit
0d6e309372
@@ -188,19 +188,8 @@ fun FirClassifierSymbol<*>.constructType(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun List<FirQualifierPart>.toTypeProjections(): Array<ConeTypeProjection> = asReversed().flatMap {
|
||||
it.typeArguments.map { typeArgument ->
|
||||
when (typeArgument) {
|
||||
is FirStarProjection -> ConeStarProjection
|
||||
is FirTypeProjectionWithVariance -> {
|
||||
val type = (typeArgument.typeRef as FirResolvedTypeRef).type
|
||||
type.toTypeProjection(typeArgument.variance)
|
||||
}
|
||||
else -> error("!")
|
||||
}
|
||||
}
|
||||
}.toTypedArray()
|
||||
private fun List<FirQualifierPart>.toTypeProjections(): Array<ConeTypeProjection> =
|
||||
asReversed().flatMap { it.typeArguments.map { typeArgument -> typeArgument.toConeTypeProjection() } }.toTypedArray()
|
||||
|
||||
fun FirFunction<*>.constructFunctionalTypeRef(session: FirSession, isSuspend: Boolean = false): FirResolvedTypeRef {
|
||||
val receiverTypeRef = when (this) {
|
||||
|
||||
+2
-7
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.builder.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirQualifierPartImpl
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -540,13 +541,7 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
|
||||
val typeOfExpression = when (val lhs = transformedGetClassCall.argument) {
|
||||
is FirResolvedQualifier -> {
|
||||
val symbol = lhs.symbol
|
||||
val typeRef =
|
||||
symbol?.constructType(
|
||||
Array((symbol.phasedFir as? FirTypeParameterRefsOwner)?.typeParameters?.size ?: 0) {
|
||||
ConeStarProjection
|
||||
},
|
||||
isNullable = false,
|
||||
)
|
||||
val typeRef = symbol?.constructType(lhs.typeArguments.map { it.toConeTypeProjection() }.toTypedArray(), isNullable = false)
|
||||
if (typeRef != null) {
|
||||
lhs.replaceTypeRef(buildResolvedTypeRef { type = typeRef })
|
||||
typeRef
|
||||
|
||||
@@ -184,6 +184,16 @@ fun ConeKotlinType.toTypeProjection(variance: Variance): ConeTypeProjection =
|
||||
Variance.OUT_VARIANCE -> ConeKotlinTypeProjectionOut(this)
|
||||
}
|
||||
|
||||
internal fun FirTypeProjection.toConeTypeProjection(): ConeTypeProjection =
|
||||
when (this) {
|
||||
is FirStarProjection -> ConeStarProjection
|
||||
is FirTypeProjectionWithVariance -> {
|
||||
val type = (this.typeRef as FirResolvedTypeRef).type
|
||||
type.toTypeProjection(this.variance)
|
||||
}
|
||||
else -> error("!")
|
||||
}
|
||||
|
||||
fun ConeClassLikeLookupTag.constructClassType(
|
||||
typeArguments: Array<out ConeTypeProjection>,
|
||||
isNullable: Boolean,
|
||||
|
||||
Reference in New Issue
Block a user