[FIR] Remove redundant lookupTag from AbstractConeSubstitutor.substituteArgument
This commit is contained in:
committed by
Space Team
parent
bd26c29229
commit
edbf199f84
+3
-5
@@ -69,11 +69,9 @@ private fun buildDeepSubstitutionMultimap(
|
||||
for (index in 0 until count) {
|
||||
val typeArgument = typeArguments[index]
|
||||
|
||||
val substitutedArgument = ConeSubstitutorByMap(substitution, session).substituteArgument(
|
||||
typeArgument,
|
||||
classSymbol.toLookupTag(),
|
||||
index
|
||||
) ?: typeArgument
|
||||
val substitutedArgument = ConeSubstitutorByMap(substitution, session)
|
||||
.substituteArgument(typeArgument, index)
|
||||
?: typeArgument
|
||||
val substitutedType = substitutedArgument.type ?: continue
|
||||
|
||||
val typeParameterSymbol = typeParameterSymbols[index]
|
||||
|
||||
+2
-3
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor
|
||||
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
import org.jetbrains.kotlin.fir.resolve.withCombinedAttributesFrom
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
@@ -105,8 +104,8 @@ private class FE10LikeConeSubstitutor(
|
||||
return withAttributes(ConeAttributes.create(listOf(OriginalProjectionTypeAttribute(projection))))
|
||||
}
|
||||
|
||||
override fun substituteArgument(projection: ConeTypeProjection, lookupTag: ConeClassLikeLookupTag, index: Int): ConeTypeProjection? {
|
||||
val substitutedProjection = super.substituteArgument(projection, lookupTag, index) ?: return null
|
||||
override fun substituteArgument(projection: ConeTypeProjection, index: Int): ConeTypeProjection? {
|
||||
val substitutedProjection = super.substituteArgument(projection, index) ?: return null
|
||||
if (substitutedProjection.isStarProjection) return null
|
||||
|
||||
val type = substitutedProjection.type!!
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeAlias
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.expandedConeType
|
||||
import org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
@@ -116,18 +115,13 @@ private fun mapTypeAliasArguments(
|
||||
return null
|
||||
}
|
||||
|
||||
override fun substituteArgument(
|
||||
projection: ConeTypeProjection,
|
||||
lookupTag: ConeClassLikeLookupTag,
|
||||
index: Int
|
||||
): ConeTypeProjection? {
|
||||
override fun substituteArgument(projection: ConeTypeProjection, index: Int): ConeTypeProjection? {
|
||||
val type = (projection as? ConeKotlinTypeProjection)?.type ?: return null
|
||||
val symbol = (type as? ConeTypeParameterType)?.lookupTag?.symbol ?: return super.substituteArgument(
|
||||
projection,
|
||||
lookupTag,
|
||||
index
|
||||
)
|
||||
val mappedProjection = typeAliasMap[symbol] ?: return super.substituteArgument(projection, lookupTag, index)
|
||||
val mappedProjection = typeAliasMap[symbol] ?: return super.substituteArgument(projection, index)
|
||||
var mappedType = (mappedProjection as? ConeKotlinTypeProjection)?.type.updateNullabilityIfNeeded(type)
|
||||
mappedType = when (mappedType) {
|
||||
is ConeErrorType,
|
||||
|
||||
+2
-3
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||
import org.jetbrains.kotlin.fir.resolve.toFirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.resolve.withCombinedAttributesFrom
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||
@@ -36,7 +35,7 @@ abstract class AbstractConeSubstitutor(protected val typeContext: ConeTypeContex
|
||||
}
|
||||
|
||||
abstract fun substituteType(type: ConeKotlinType): ConeKotlinType?
|
||||
open fun substituteArgument(projection: ConeTypeProjection, lookupTag: ConeClassLikeLookupTag, index: Int): ConeTypeProjection? {
|
||||
open fun substituteArgument(projection: ConeTypeProjection, index: Int): ConeTypeProjection? {
|
||||
val type = (projection as? ConeKotlinTypeProjection)?.type ?: return null
|
||||
val newType = substituteOrNull(type) ?: return null
|
||||
return wrapProjection(projection, newType)
|
||||
@@ -139,7 +138,7 @@ abstract class AbstractConeSubstitutor(protected val typeContext: ConeTypeContex
|
||||
require(this is ConeClassLikeType) { "Unknown type to substitute: $this, ${this::class}" }
|
||||
|
||||
for ((index, typeArgument) in this.typeArguments.withIndex()) {
|
||||
newArguments[index] = substituteArgument(typeArgument, lookupTag, index)?.also {
|
||||
newArguments[index] = substituteArgument(typeArgument, index)?.also {
|
||||
initialized = true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user