[Commonizer] Remove CirTypeSignature from CirType
This commit is contained in:
@@ -11,9 +11,7 @@ import org.jetbrains.kotlin.types.Variance
|
|||||||
|
|
||||||
typealias CirTypeSignature = String
|
typealias CirTypeSignature = String
|
||||||
|
|
||||||
sealed class CirType {
|
sealed class CirType
|
||||||
abstract val signature: CirTypeSignature
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All attributes are read from the abbreviation type: [AbbreviatedType.abbreviation].
|
* All attributes are read from the abbreviation type: [AbbreviatedType.abbreviation].
|
||||||
@@ -33,9 +31,6 @@ abstract class CirSimpleType : CirType(), CirHasVisibility {
|
|||||||
abstract val isDefinitelyNotNullType: Boolean
|
abstract val isDefinitelyNotNullType: Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
data class CirTypeProjection(val projectionKind: Variance, val isStarProjection: Boolean, val type: CirType)
|
data class CirFlexibleType(val lowerBound: CirSimpleType, val upperBound: CirSimpleType) : CirType()
|
||||||
|
|
||||||
data class CirFlexibleType(val lowerBound: CirSimpleType, val upperBound: CirSimpleType) : CirType() {
|
data class CirTypeProjection(val projectionKind: Variance, val isStarProjection: Boolean, val type: CirType)
|
||||||
override val signature: CirTypeSignature
|
|
||||||
get() = lowerBound.signature
|
|
||||||
}
|
|
||||||
|
|||||||
+3
-7
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
|||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirSimpleTypeImpl
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirSimpleTypeImpl
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.Interner
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.Interner
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.declarationDescriptor
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.declarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.signature
|
|
||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.*
|
||||||
|
|
||||||
object CirTypeFactory {
|
object CirTypeFactory {
|
||||||
@@ -41,8 +40,7 @@ object CirTypeFactory {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
isMarkedNullable = abbreviation.isMarkedNullable,
|
isMarkedNullable = abbreviation.isMarkedNullable,
|
||||||
isDefinitelyNotNullType = abbreviation.isDefinitelyNotNullType,
|
isDefinitelyNotNullType = abbreviation.isDefinitelyNotNullType
|
||||||
signature = source.signature
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,8 +49,7 @@ object CirTypeFactory {
|
|||||||
visibility: Visibility,
|
visibility: Visibility,
|
||||||
arguments: List<CirTypeProjection>,
|
arguments: List<CirTypeProjection>,
|
||||||
isMarkedNullable: Boolean,
|
isMarkedNullable: Boolean,
|
||||||
isDefinitelyNotNullType: Boolean,
|
isDefinitelyNotNullType: Boolean
|
||||||
signature: CirTypeSignature
|
|
||||||
): CirSimpleType {
|
): CirSimpleType {
|
||||||
return interner.intern(
|
return interner.intern(
|
||||||
CirSimpleTypeImpl(
|
CirSimpleTypeImpl(
|
||||||
@@ -60,8 +57,7 @@ object CirTypeFactory {
|
|||||||
visibility = visibility,
|
visibility = visibility,
|
||||||
arguments = arguments,
|
arguments = arguments,
|
||||||
isMarkedNullable = isMarkedNullable,
|
isMarkedNullable = isMarkedNullable,
|
||||||
isDefinitelyNotNullType = isDefinitelyNotNullType,
|
isDefinitelyNotNullType = isDefinitelyNotNullType
|
||||||
signature = signature
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-4
@@ -15,8 +15,7 @@ data class CirSimpleTypeImpl(
|
|||||||
override val visibility: Visibility, // visibility of the classifier descriptor
|
override val visibility: Visibility, // visibility of the classifier descriptor
|
||||||
override val arguments: List<CirTypeProjection>,
|
override val arguments: List<CirTypeProjection>,
|
||||||
override val isMarkedNullable: Boolean,
|
override val isMarkedNullable: Boolean,
|
||||||
override val isDefinitelyNotNullType: Boolean,
|
override val isDefinitelyNotNullType: Boolean
|
||||||
override val signature: CirTypeSignature
|
|
||||||
) : CirSimpleType() {
|
) : CirSimpleType() {
|
||||||
// See also org.jetbrains.kotlin.types.KotlinType.cachedHashCode
|
// See also org.jetbrains.kotlin.types.KotlinType.cachedHashCode
|
||||||
private var cachedHashCode = 0
|
private var cachedHashCode = 0
|
||||||
@@ -26,7 +25,6 @@ data class CirSimpleTypeImpl(
|
|||||||
.appendHashCode(arguments)
|
.appendHashCode(arguments)
|
||||||
.appendHashCode(isMarkedNullable)
|
.appendHashCode(isMarkedNullable)
|
||||||
.appendHashCode(isDefinitelyNotNullType)
|
.appendHashCode(isDefinitelyNotNullType)
|
||||||
.appendHashCode(signature)
|
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
var currentHashCode = cachedHashCode
|
var currentHashCode = cachedHashCode
|
||||||
@@ -44,7 +42,6 @@ data class CirSimpleTypeImpl(
|
|||||||
&& classifierId == other.classifierId
|
&& classifierId == other.classifierId
|
||||||
&& visibility == other.visibility
|
&& visibility == other.visibility
|
||||||
&& arguments == other.arguments
|
&& arguments == other.arguments
|
||||||
&& signature == other.signature
|
|
||||||
&& isDefinitelyNotNullType == other.isDefinitelyNotNullType
|
&& isDefinitelyNotNullType == other.isDefinitelyNotNullType
|
||||||
}
|
}
|
||||||
else -> false
|
else -> false
|
||||||
|
|||||||
+1
-2
@@ -165,8 +165,7 @@ private class DeprecatedAnnotationCommonizer : Commonizer<CirAnnotation, CirAnno
|
|||||||
visibility = Visibilities.PUBLIC,
|
visibility = Visibilities.PUBLIC,
|
||||||
arguments = emptyList(),
|
arguments = emptyList(),
|
||||||
isMarkedNullable = false,
|
isMarkedNullable = false,
|
||||||
isDefinitelyNotNullType = false,
|
isDefinitelyNotNullType = false
|
||||||
signature = classId.asString()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun CirAnnotation.getDeprecationMessage(): String? = constantValueArguments.getString(PROPERTY_NAME_MESSAGE)
|
private fun CirAnnotation.getDeprecationMessage(): String? = constantValueArguments.getString(PROPERTY_NAME_MESSAGE)
|
||||||
|
|||||||
+2
-3
@@ -6,7 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeSignature
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.*
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.*
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.internedClassId
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.internedClassId
|
||||||
@@ -93,10 +92,10 @@ internal class CommonizationVisitor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// find out common (and commonized) supertypes
|
// find out common (and commonized) supertypes
|
||||||
val supertypesMap: MutableMap<CirTypeSignature, CommonizedGroup<CirType>> = linkedMapOf() // preserve supertype order
|
val supertypesMap: MutableMap<CirType, CommonizedGroup<CirType>> = linkedMapOf() // preserve supertype order
|
||||||
node.targetDeclarations.forEachIndexed { index, clazz ->
|
node.targetDeclarations.forEachIndexed { index, clazz ->
|
||||||
for (supertype in clazz!!.supertypes) {
|
for (supertype in clazz!!.supertypes) {
|
||||||
supertypesMap.getOrPut(supertype.signature) { CommonizedGroup(node.targetDeclarations.size) }[index] = supertype
|
supertypesMap.getOrPut(supertype) { CommonizedGroup(node.targetDeclarations.size) }[index] = supertype
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user