[Commonizer] Remove classifierId from CIR class/TA nodes
This commit is contained in:
+3
-4
@@ -85,9 +85,8 @@ internal class CommonizationVisitor(
|
||||
// companion object should have the same name for each target class, then it could be set to common class
|
||||
val companionObjectName = node.targetDeclarations.mapTo(HashSet()) { it!!.companion }.singleOrNull()
|
||||
if (companionObjectName != null) {
|
||||
val companionObjectClassId = node.classifierId.createNestedEntityId(companionObjectName)
|
||||
val companionObjectNode = classifiers.commonized.classNode(companionObjectClassId)
|
||||
?: error("Can't find companion object with class ID $companionObjectClassId")
|
||||
val companionObjectNode = node.classes[companionObjectName]
|
||||
?: error("Can't find node for companion object $companionObjectName in node for class ${node.classifierName}")
|
||||
|
||||
if (companionObjectNode.commonDeclaration() != null) {
|
||||
// companion object has been successfully commonized
|
||||
@@ -132,7 +131,7 @@ internal class CommonizationVisitor(
|
||||
|
||||
val expandedClassNode = classifiers.commonized.classNode(expandedClassId) ?: return null
|
||||
val expandedClass = expandedClassNode.targetDeclarations[index]
|
||||
?: error("Can't find expanded class with class ID $expandedClassId and index $index for type alias $classifierId")
|
||||
?: error("Can't find expanded class with class ID $expandedClassId and index $index for type alias $classifierName")
|
||||
|
||||
for (supertype in expandedClass.supertypes) {
|
||||
supertypesMap.getOrPut(supertype) { CommonizedGroup(targetDeclarations.size) }[index] = supertype
|
||||
|
||||
+1
-3
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.descriptors.commonizer.mergedtree
|
||||
|
||||
import gnu.trove.THashMap
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirClass
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
||||
import org.jetbrains.kotlin.storage.NullableLazyValue
|
||||
@@ -15,8 +14,7 @@ import org.jetbrains.kotlin.storage.NullableLazyValue
|
||||
class CirClassNode(
|
||||
override val targetDeclarations: CommonizedGroup<CirClass>,
|
||||
override val commonDeclaration: NullableLazyValue<CirClass>,
|
||||
override val classifierId: CirEntityId
|
||||
) : CirNodeWithClassifierId<CirClass, CirClass>, CirNodeWithMembers<CirClass, CirClass> {
|
||||
) : CirClassifierNode<CirClass, CirClass>, CirNodeWithMembers<CirClass, CirClass> {
|
||||
|
||||
val constructors: MutableMap<ConstructorApproximationKey, CirClassConstructorNode> = THashMap()
|
||||
override val properties: MutableMap<PropertyApproximationKey, CirPropertyNode> = THashMap()
|
||||
|
||||
+6
-4
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.descriptors.commonizer.mergedtree
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.firstNonNull
|
||||
import org.jetbrains.kotlin.storage.NullableLazyValue
|
||||
|
||||
interface CirNode<T : CirDeclaration, R : CirDeclaration> {
|
||||
@@ -26,8 +27,8 @@ interface CirNode<T : CirDeclaration, R : CirDeclaration> {
|
||||
if (node is CirPackageNode) {
|
||||
append("packageName=").append(node.packageName).append(", ")
|
||||
}
|
||||
if (node is CirNodeWithClassifierId) {
|
||||
append("classifierId=").append(node.classifierId).append(", ")
|
||||
if (node is CirClassifierNode) {
|
||||
append("classifierName=").append(node.classifierName).append(", ")
|
||||
}
|
||||
append("target=")
|
||||
node.targetDeclarations.joinTo(this)
|
||||
@@ -37,8 +38,9 @@ interface CirNode<T : CirDeclaration, R : CirDeclaration> {
|
||||
}
|
||||
}
|
||||
|
||||
interface CirNodeWithClassifierId<T : CirClassifier, R : CirClassifier> : CirNode<T, R> {
|
||||
val classifierId: CirEntityId
|
||||
interface CirClassifierNode<T : CirClassifier, R : CirClassifier> : CirNode<T, R> {
|
||||
val classifierName: CirName
|
||||
get() = targetDeclarations.firstNonNull<CirClassifier>().name
|
||||
}
|
||||
|
||||
interface CirNodeWithLiftingUp<T : CirDeclaration, R : CirDeclaration> : CirNode<T, R> {
|
||||
|
||||
+1
-3
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.descriptors.commonizer.mergedtree
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirClassifier
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeAlias
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup
|
||||
import org.jetbrains.kotlin.storage.NullableLazyValue
|
||||
@@ -14,8 +13,7 @@ import org.jetbrains.kotlin.storage.NullableLazyValue
|
||||
class CirTypeAliasNode(
|
||||
override val targetDeclarations: CommonizedGroup<CirTypeAlias>,
|
||||
override val commonDeclaration: NullableLazyValue<CirClassifier>,
|
||||
override val classifierId: CirEntityId
|
||||
) : CirNodeWithClassifierId<CirTypeAlias, CirClassifier>, CirNodeWithLiftingUp<CirTypeAlias, CirClassifier> {
|
||||
) : CirClassifierNode<CirTypeAlias, CirClassifier>, CirNodeWithLiftingUp<CirTypeAlias, CirClassifier> {
|
||||
|
||||
override fun <T, R> accept(visitor: CirNodeVisitor<T, R>, data: T): R =
|
||||
visitor.visitTypeAliasNode(this, data)
|
||||
|
||||
+2
-2
@@ -83,7 +83,7 @@ internal fun buildClassNode(
|
||||
commonizerProducer = { ClassCommonizer(classifiers) },
|
||||
recursionMarker = CirClassRecursionMarker,
|
||||
nodeProducer = { targetDeclarations, commonDeclaration ->
|
||||
CirClassNode(targetDeclarations, commonDeclaration, classId).also {
|
||||
CirClassNode(targetDeclarations, commonDeclaration).also {
|
||||
classifiers.commonized.addClassNode(classId, it)
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ internal fun buildTypeAliasNode(
|
||||
commonizerProducer = { TypeAliasCommonizer(classifiers) },
|
||||
recursionMarker = CirClassifierRecursionMarker,
|
||||
nodeProducer = { targetDeclarations, commonDeclaration ->
|
||||
CirTypeAliasNode(targetDeclarations, commonDeclaration, typeAliasId).also {
|
||||
CirTypeAliasNode(targetDeclarations, commonDeclaration).also {
|
||||
classifiers.commonized.addTypeAliasNode(typeAliasId, it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,8 +138,7 @@ internal val MOCK_CLASSIFIERS = CirKnownClassifiers(
|
||||
isInner = false,
|
||||
isExternal = false
|
||||
)
|
||||
},
|
||||
CirEntityId.create("kotlin/Any")
|
||||
}
|
||||
)
|
||||
|
||||
override fun classNode(classId: CirEntityId) = MOCK_CLASS_NODE
|
||||
|
||||
Reference in New Issue
Block a user