[Commonizer] Minor. Rename: CirTypeProjectionImpl -> CirRegularTypeProjection

This commit is contained in:
Dmitriy Dolovov
2021-03-05 02:39:32 +03:00
parent 6b0f080ed8
commit 4f33abf5e4
6 changed files with 17 additions and 17 deletions
@@ -159,7 +159,7 @@ object CirStarTypeProjection : CirTypeProjection() {
override fun toString() = "*"
}
data class CirTypeProjectionImpl(val projectionKind: Variance, val type: CirType) : CirTypeProjection() {
data class CirRegularTypeProjection(val projectionKind: Variance, val type: CirType) : CirTypeProjection() {
override fun toString() = buildString {
append(projectionKind)
if (isNotEmpty()) append(' ')
@@ -45,14 +45,14 @@ fun CirClassOrTypeAliasType.unabbreviate(): CirClassType = when (this) {
var hasAbbreviationsInArguments = false
val unabbreviatedArguments = arguments.compactMap { argument ->
val argumentType =
(argument as? CirTypeProjectionImpl)?.type as? CirClassOrTypeAliasType ?: return@compactMap argument
(argument as? CirRegularTypeProjection)?.type as? CirClassOrTypeAliasType ?: return@compactMap argument
val unabbreviatedArgumentType = argumentType.unabbreviate()
if (argumentType == unabbreviatedArgumentType)
argument
else {
hasAbbreviationsInArguments = true
CirTypeProjectionImpl(
CirRegularTypeProjection(
projectionKind = argument.projectionKind,
type = unabbreviatedArgumentType
)
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.descriptors.commonizer.core
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirStarTypeProjection
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeProjection
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeProjectionImpl
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirRegularTypeProjection
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirKnownClassifiers
import org.jetbrains.kotlin.types.Variance
@@ -18,7 +18,7 @@ class TypeArgumentCommonizer(
private lateinit var projectionKind: Variance
private val type = TypeCommonizer(classifiers)
override fun commonizationResult() = if (isStar) CirStarTypeProjection else CirTypeProjectionImpl(
override fun commonizationResult() = if (isStar) CirStarTypeProjection else CirRegularTypeProjection(
projectionKind = projectionKind,
type = type.result
)
@@ -26,12 +26,12 @@ class TypeArgumentCommonizer(
override fun initialize(first: CirTypeProjection) {
when (first) {
is CirStarTypeProjection -> isStar = true
is CirTypeProjectionImpl -> projectionKind = first.projectionKind
is CirRegularTypeProjection -> projectionKind = first.projectionKind
}
}
override fun doCommonizeWith(next: CirTypeProjection) = when (next) {
is CirStarTypeProjection -> isStar
is CirTypeProjectionImpl -> !isStar && projectionKind == next.projectionKind && type.commonizeWith(next.type)
is CirRegularTypeProjection -> !isStar && projectionKind == next.projectionKind && type.commonizeWith(next.type)
}
}
@@ -34,7 +34,7 @@ object CirDeserializers {
outerType = null, // annotation class can't be inner class
visibility = clazz.visibility,
arguments = clazz.typeParameters.compactMap { typeParameter ->
CirTypeProjectionImpl(
CirRegularTypeProjection(
projectionKind = typeParameter.variance,
type = CirTypeParameterType.createInterned(
index = typeParameter.index,
@@ -398,7 +398,7 @@ object CirDeserializers {
val variance = argument.variance ?: return@compactMap CirStarTypeProjection
val argumentType = argument.type ?: return@compactMap CirStarTypeProjection
CirTypeProjectionImpl(
CirRegularTypeProjection(
projectionKind = variance(variance),
type = type(argumentType, typeResolver)
)
@@ -42,7 +42,7 @@ object CirTypeAliasExpander {
val underlyingProjection = CirProvided.RegularTypeProjection(Variance.INVARIANT, underlyingType)
val expandedProjection = expandTypeProjection(expansion, underlyingProjection, Variance.INVARIANT)
check(expandedProjection is CirTypeProjectionImpl) {
check(expandedProjection is CirRegularTypeProjection) {
"Type alias expansion: result for $underlyingType is $expandedProjection, should not be a star projection"
}
check(expandedProjection.projectionKind == Variance.INVARIANT) {
@@ -67,17 +67,17 @@ object CirTypeAliasExpander {
is CirProvided.TypeParameterType -> expansion.arguments[type.index]
is CirProvided.TypeAliasType -> {
val substitutedType = expandTypeAliasType(expansion, type)
CirTypeProjectionImpl(projection.variance, substitutedType)
CirRegularTypeProjection(projection.variance, substitutedType)
}
is CirProvided.ClassType -> {
val substitutedType = expandClassType(expansion, type)
CirTypeProjectionImpl(projection.variance, substitutedType)
CirRegularTypeProjection(projection.variance, substitutedType)
}
}
return when (argument) {
is CirStarTypeProjection -> CirStarTypeProjection
is CirTypeProjectionImpl -> {
is CirRegularTypeProjection -> {
val argumentType = argument.type as CirSimpleType
val resultingVariance = run {
@@ -101,7 +101,7 @@ object CirTypeAliasExpander {
val substitutedType = argumentType.makeNullableIfNecessary(type.isMarkedNullable)
CirTypeProjectionImpl(resultingVariance, substitutedType)
CirRegularTypeProjection(resultingVariance, substitutedType)
}
}
}
@@ -157,7 +157,7 @@ object CirTypeAliasExpander {
): CirTypeProjection {
return when (projection) {
is CirStarTypeProjection -> CirStarTypeProjection
is CirTypeProjectionImpl -> {
is CirRegularTypeProjection -> {
val originalTypeIsNullable = (originalArgument as? CirProvided.RegularTypeProjection)?.type?.isMarkedNullable == true
if (!originalTypeIsNullable)
return projection
@@ -166,7 +166,7 @@ object CirTypeAliasExpander {
if (projectionType.isMarkedNullable)
return projection
CirTypeProjectionImpl(
CirRegularTypeProjection(
projectionKind = projection.projectionKind,
type = projectionType.makeNullable()
)
@@ -340,7 +340,7 @@ private fun CirTypeProjection.buildArgument(
val effectiveExpansion = if (expansion == FOR_TOP_LEVEL_TYPE) FOR_NESTED_TYPE else expansion
return when (this) {
CirStarTypeProjection -> KmTypeProjection.STAR
is CirTypeProjectionImpl -> KmTypeProjection(
is CirRegularTypeProjection -> KmTypeProjection(
variance = projectionKind.buildVariance(),
type = type.buildType(context, effectiveExpansion)
)