[Commonizer] Drop CirTypeParameter interface for plain data class

This commit is contained in:
sebastian.sellmair
2021-07-07 16:43:38 +02:00
committed by Space
parent 4a4516731a
commit fdee49ee59
4 changed files with 8 additions and 31 deletions
@@ -7,33 +7,10 @@ package org.jetbrains.kotlin.commonizer.cir
import org.jetbrains.kotlin.types.Variance
interface CirTypeParameter : CirHasAnnotations, CirHasName {
val isReified: Boolean
val variance: Variance
val upperBounds: List<CirType>
companion object {
@Suppress("NOTHING_TO_INLINE")
inline fun create(
annotations: List<CirAnnotation>,
name: CirName,
isReified: Boolean,
variance: Variance,
upperBounds: List<CirType>
): CirTypeParameter = CirTypeParameterImpl(
annotations = annotations,
name = name,
isReified = isReified,
variance = variance,
upperBounds = upperBounds
)
}
}
data class CirTypeParameterImpl(
data class CirTypeParameter(
override val annotations: List<CirAnnotation>,
override val name: CirName,
override val isReified: Boolean,
override val variance: Variance,
override val upperBounds: List<CirType>
) : CirTypeParameter
val isReified: Boolean,
val variance: Variance,
val upperBounds: List<CirType>
) : CirHasAnnotations, CirHasName
@@ -17,7 +17,7 @@ class TypeParameterCommonizer(classifiers: CirKnownClassifiers) : AbstractStanda
private lateinit var variance: Variance
private val upperBounds = TypeParameterUpperBoundsCommonizer(classifiers)
override fun commonizationResult() = CirTypeParameter.create(
override fun commonizationResult() = CirTypeParameter(
annotations = emptyList(),
name = name,
isReified = isReified,
@@ -73,7 +73,7 @@ object CirDeserializers {
private val ALWAYS_HAS_ANNOTATIONS: Flags = flagsOf(Flag.Common.HAS_ANNOTATIONS)
private fun typeParameter(source: KmTypeParameter, typeResolver: CirTypeResolver): CirTypeParameter = CirTypeParameter.create(
private fun typeParameter(source: KmTypeParameter, typeResolver: CirTypeResolver): CirTypeParameter = CirTypeParameter(
annotations = annotations(ALWAYS_HAS_ANNOTATIONS, typeResolver, source::annotations),
name = CirName.create(source.name),
isReified = Flag.TypeParameter.IS_REIFIED(source.flags),
@@ -86,7 +86,7 @@ class TypeParameterCommonizerTest : AbstractCommonizerTest<CirTypeParameter, Cir
isReified: Boolean = false,
variance: Variance = Variance.INVARIANT,
upperBounds: List<String> = listOf("kotlin/Any")
) = CirTypeParameter.create(
) = CirTypeParameter(
annotations = emptyList(),
name = CirName.create(name),
isReified = isReified,