[Commonizer] Remove CirClassType.visibility
^KT-48288
This commit is contained in:
committed by
Space
parent
da1eb5d96e
commit
ba997905d9
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.commonizer.cir
|
||||
|
||||
import org.jetbrains.kotlin.commonizer.mergedtree.CirProvided
|
||||
import org.jetbrains.kotlin.commonizer.mergedtree.CirProvidedClassifiers
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
|
||||
internal fun CirProvided.ClassOrTypeAliasType.toCirClassOrTypeAliasTypeOrNull(classifiers: CirProvidedClassifiers): CirClassOrTypeAliasType? {
|
||||
return when (this) {
|
||||
@@ -32,7 +31,6 @@ internal fun CirProvided.ClassType.toCirClassTypeOrNull(classifiers: CirProvided
|
||||
outerType = outerType?.let { it.toCirClassTypeOrNull(classifiers) ?: return null },
|
||||
isMarkedNullable = isMarkedNullable,
|
||||
arguments = arguments.map { it.toCirTypeProjection(classifiers) ?: return null },
|
||||
visibility = Visibilities.Public,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,11 @@
|
||||
package org.jetbrains.kotlin.commonizer.cir
|
||||
|
||||
import org.jetbrains.kotlin.commonizer.utils.ANY_CLASS_ID
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
|
||||
object CirStandardTypes {
|
||||
val ANY: CirClassType = CirClassType.createInterned(
|
||||
classId = ANY_CLASS_ID,
|
||||
outerType = null,
|
||||
visibility = Visibilities.Public,
|
||||
arguments = emptyList(),
|
||||
isMarkedNullable = false
|
||||
)
|
||||
|
||||
@@ -9,7 +9,6 @@ import kotlinx.metadata.KmType
|
||||
import org.jetbrains.kotlin.commonizer.utils.Interner
|
||||
import org.jetbrains.kotlin.commonizer.utils.appendHashCode
|
||||
import org.jetbrains.kotlin.commonizer.utils.hashCode
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
|
||||
@@ -87,7 +86,7 @@ sealed class CirClassOrTypeAliasType : CirSimpleType() {
|
||||
abstract fun withArguments(arguments: List<CirTypeProjection>): CirClassOrTypeAliasType
|
||||
}
|
||||
|
||||
abstract class CirClassType : CirClassOrTypeAliasType(), CirHasVisibility {
|
||||
abstract class CirClassType : CirClassOrTypeAliasType() {
|
||||
abstract val outerType: CirClassType?
|
||||
|
||||
override fun appendDescriptionTo(builder: StringBuilder, shortNameOnly: Boolean) {
|
||||
@@ -104,7 +103,6 @@ abstract class CirClassType : CirClassOrTypeAliasType(), CirHasVisibility {
|
||||
return createInterned(
|
||||
classId = classifierId,
|
||||
outerType = outerType,
|
||||
visibility = visibility,
|
||||
arguments = arguments,
|
||||
isMarkedNullable = isMarkedNullable
|
||||
)
|
||||
@@ -114,14 +112,12 @@ abstract class CirClassType : CirClassOrTypeAliasType(), CirHasVisibility {
|
||||
fun createInterned(
|
||||
classId: CirEntityId,
|
||||
outerType: CirClassType?,
|
||||
visibility: Visibility,
|
||||
arguments: List<CirTypeProjection>,
|
||||
isMarkedNullable: Boolean
|
||||
): CirClassType = interner.intern(
|
||||
CirClassTypeInternedImpl(
|
||||
classifierId = classId,
|
||||
outerType = outerType,
|
||||
visibility = visibility,
|
||||
arguments = arguments,
|
||||
isMarkedNullable = isMarkedNullable
|
||||
)
|
||||
@@ -130,14 +126,12 @@ abstract class CirClassType : CirClassOrTypeAliasType(), CirHasVisibility {
|
||||
fun CirClassType.copyInterned(
|
||||
classifierId: CirEntityId = this.classifierId,
|
||||
outerType: CirClassType? = this.outerType,
|
||||
visibility: Visibility = this.visibility,
|
||||
arguments: List<CirTypeProjection> = this.arguments,
|
||||
isMarkedNullable: Boolean = this.isMarkedNullable
|
||||
): CirClassType {
|
||||
return createInterned(
|
||||
classId = classifierId,
|
||||
outerType = outerType,
|
||||
visibility = visibility,
|
||||
arguments = arguments,
|
||||
isMarkedNullable = isMarkedNullable
|
||||
)
|
||||
@@ -227,33 +221,21 @@ private data class CirTypeParameterTypeInternedImpl(
|
||||
private class CirClassTypeInternedImpl(
|
||||
override val classifierId: CirEntityId,
|
||||
override val outerType: CirClassType?,
|
||||
override val visibility: Visibility, // visibility of the class descriptor
|
||||
override val arguments: List<CirTypeProjection>,
|
||||
override val isMarkedNullable: Boolean,
|
||||
) : CirClassType() {
|
||||
// See also org.jetbrains.kotlin.types.KotlinType.cachedHashCode
|
||||
private var cachedHashCode = 0
|
||||
|
||||
private fun computeHashCode() = hashCode(classifierId)
|
||||
private val hashCode = hashCode(classifierId)
|
||||
.appendHashCode(outerType)
|
||||
.appendHashCode(visibility)
|
||||
.appendHashCode(arguments)
|
||||
.appendHashCode(isMarkedNullable)
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var currentHashCode = cachedHashCode
|
||||
if (currentHashCode != 0) return currentHashCode
|
||||
|
||||
currentHashCode = computeHashCode()
|
||||
cachedHashCode = currentHashCode
|
||||
return currentHashCode
|
||||
}
|
||||
override fun hashCode(): Int = hashCode
|
||||
|
||||
override fun equals(other: Any?): Boolean = when {
|
||||
other === this -> true
|
||||
other is CirClassType -> classifierId == other.classifierId
|
||||
&& isMarkedNullable == other.isMarkedNullable
|
||||
&& visibility == other.visibility
|
||||
&& arguments == other.arguments
|
||||
&& outerType == other.outerType
|
||||
else -> false
|
||||
|
||||
@@ -15,7 +15,6 @@ fun <T : CirSimpleType> T.makeNullable(): T {
|
||||
is CirClassType -> CirClassType.createInterned(
|
||||
classId = classifierId,
|
||||
outerType = outerType,
|
||||
visibility = visibility,
|
||||
arguments = arguments,
|
||||
isMarkedNullable = true
|
||||
)
|
||||
@@ -68,7 +67,6 @@ fun CirClassOrTypeAliasType.unabbreviate(): CirClassType = when (this) {
|
||||
CirClassType.createInterned(
|
||||
classId = classifierId,
|
||||
outerType = unabbreviatedOuterType,
|
||||
visibility = visibility,
|
||||
arguments = unabbreviatedArguments,
|
||||
isMarkedNullable = isMarkedNullable
|
||||
)
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.commonizer.cir.*
|
||||
import org.jetbrains.kotlin.commonizer.cir.CirConstantValue.*
|
||||
import org.jetbrains.kotlin.commonizer.core.AnnotationsCommonizer.Companion.FALLBACK_MESSAGE
|
||||
import org.jetbrains.kotlin.commonizer.utils.*
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import kotlin.DeprecationLevel.WARNING
|
||||
|
||||
/**
|
||||
@@ -74,7 +73,7 @@ object ObjCInteropCallableAnnotationCommonizer : AssociativeCommonizer<List<CirA
|
||||
private val objCCallableAnnotation = CirAnnotation.createInterned(
|
||||
CirClassType.createInterned(
|
||||
classId = COMMONIZER_OBJC_INTEROP_CALLABLE_ANNOTATION_ID,
|
||||
outerType = null, visibility = Visibilities.Public, arguments = emptyList(), isMarkedNullable = false
|
||||
outerType = null, arguments = emptyList(), isMarkedNullable = false
|
||||
),
|
||||
constantValueArguments = emptyMap(),
|
||||
annotationValueArguments = emptyMap()
|
||||
@@ -195,7 +194,6 @@ private class DeprecatedAnnotationCommonizer : Commonizer<CirAnnotation, CirAnno
|
||||
private fun buildAnnotationType(classId: CirEntityId) = CirClassType.createInterned(
|
||||
classId = classId,
|
||||
outerType = null,
|
||||
visibility = Visibilities.Public,
|
||||
arguments = emptyList(),
|
||||
isMarkedNullable = false
|
||||
)
|
||||
|
||||
-4
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.commonizer.mergedtree.*
|
||||
import org.jetbrains.kotlin.commonizer.utils.isUnderKotlinNativeSyntheticPackages
|
||||
import org.jetbrains.kotlin.commonizer.utils.safeCastValues
|
||||
import org.jetbrains.kotlin.commonizer.utils.singleDistinctValueOrNull
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.ifTrue
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
@@ -47,7 +46,6 @@ internal class ClassOrTypeAliasTypeCommonizer(
|
||||
classId = classifierId,
|
||||
outerType = outerType,
|
||||
arguments = arguments,
|
||||
visibility = Visibilities.Public,
|
||||
isMarkedNullable = isMarkedNullable
|
||||
)
|
||||
}
|
||||
@@ -57,7 +55,6 @@ internal class ClassOrTypeAliasTypeCommonizer(
|
||||
classId = classifierId,
|
||||
outerType = outerType,
|
||||
arguments = arguments,
|
||||
visibility = Visibilities.Public,
|
||||
isMarkedNullable = isMarkedNullable
|
||||
)
|
||||
|
||||
@@ -80,7 +77,6 @@ internal class ClassOrTypeAliasTypeCommonizer(
|
||||
classId = classifierId,
|
||||
outerType = outerType,
|
||||
arguments = arguments,
|
||||
visibility = Visibilities.Public,
|
||||
isMarkedNullable = isMarkedNullable
|
||||
)
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.commonizer.CommonizerTarget
|
||||
import org.jetbrains.kotlin.commonizer.allLeaves
|
||||
import org.jetbrains.kotlin.commonizer.cir.*
|
||||
import org.jetbrains.kotlin.commonizer.mergedtree.CirKnownClassifiers
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
|
||||
class TypeAliasCommonizer(
|
||||
@@ -90,7 +89,6 @@ private class UnsafeNumberAnnotation(val actualPlatformTypes: Map<String, CirEnt
|
||||
private val type = CirClassType.createInterned(
|
||||
classId = CirEntityId.create("kotlinx/cinterop/UnsafeNumber"),
|
||||
outerType = null,
|
||||
visibility = Visibilities.Public,
|
||||
arguments = emptyList(),
|
||||
isMarkedNullable = false
|
||||
)
|
||||
|
||||
@@ -32,7 +32,6 @@ object CirDeserializers {
|
||||
val type = CirClassType.createInterned(
|
||||
classId = classId,
|
||||
outerType = null, // annotation class can't be inner class
|
||||
visibility = clazz.visibility,
|
||||
arguments = clazz.typeParameters.compactMap { typeParameter ->
|
||||
CirRegularTypeProjection(
|
||||
projectionKind = typeParameter.variance,
|
||||
@@ -274,7 +273,6 @@ object CirDeserializers {
|
||||
name: CirName,
|
||||
annotations: List<KmAnnotation>,
|
||||
enumClassId: CirEntityId,
|
||||
enumClass: KmClass,
|
||||
typeResolver: CirTypeResolver
|
||||
): CirClass = CirClass.create(
|
||||
annotations = annotations.compactMap { annotation(it, typeResolver) },
|
||||
@@ -284,7 +282,6 @@ object CirDeserializers {
|
||||
CirClassType.createInterned(
|
||||
classId = enumClassId,
|
||||
outerType = null,
|
||||
visibility = visibility(enumClass.flags),
|
||||
arguments = emptyList(),
|
||||
isMarkedNullable = false
|
||||
)
|
||||
@@ -357,7 +354,6 @@ object CirDeserializers {
|
||||
CirClassType.createInterned(
|
||||
classId = (clazz as? CirProvided.ExportedForwardDeclarationClass)?.syntheticClassId ?: classId,
|
||||
outerType = outerType,
|
||||
visibility = clazz.visibility,
|
||||
arguments = arguments(source.arguments, typeResolver),
|
||||
isMarkedNullable = isMarkedNullable
|
||||
)
|
||||
|
||||
@@ -144,7 +144,6 @@ object CirTypeAliasExpander {
|
||||
return CirClassType.createInterned(
|
||||
classId = type.classifierId,
|
||||
outerType = type.outerType?.let { expandClassType(expansion, it) },
|
||||
visibility = clazz.visibility,
|
||||
arguments = expandedArguments,
|
||||
isMarkedNullable = type.isMarkedNullable
|
||||
)
|
||||
|
||||
-1
@@ -40,7 +40,6 @@ internal class CirTreeClassDeserializer(
|
||||
name = className,
|
||||
annotations = classEntry.annotations,
|
||||
enumClassId = classEntry.enumClassId,
|
||||
enumClass = classEntry.enumClass,
|
||||
typeResolver = classTypeResolver
|
||||
)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ internal fun mockClassType(
|
||||
): CirClassType = CirClassType.createInterned(
|
||||
classId = createValidClassifierId(classId),
|
||||
outerType = null,
|
||||
visibility = Visibilities.Public,
|
||||
arguments = emptyList(),
|
||||
isMarkedNullable = nullable
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user