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