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