[Commonizer] Rename: CirCommonizedClassifiers -> CirCommonizedClassifierNodes
This commit is contained in:
+1
-1
@@ -129,7 +129,7 @@ internal class CommonizationVisitor(
|
|||||||
if (classifiers.commonDependencies.hasClassifier(expandedClassId))
|
if (classifiers.commonDependencies.hasClassifier(expandedClassId))
|
||||||
return null // this case is not supported yet
|
return null // this case is not supported yet
|
||||||
|
|
||||||
val expandedClassNode = classifiers.commonized.classNode(expandedClassId) ?: return null
|
val expandedClassNode = classifiers.commonizedNodes.classNode(expandedClassId) ?: return null
|
||||||
val expandedClass = expandedClassNode.targetDeclarations[index]
|
val expandedClass = expandedClassNode.targetDeclarations[index]
|
||||||
?: error("Can't find expanded class with class ID $expandedClassId and index $index for type alias $classifierName")
|
?: error("Can't find expanded class with class ID $expandedClassId and index $index for type alias $classifierName")
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -204,7 +204,7 @@ private fun commonizeClass(classId: CirEntityId, classifiers: CirKnownClassifier
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return when (val node = classifiers.commonized.classNode(classId)) {
|
return when (val node = classifiers.commonizedNodes.classNode(classId)) {
|
||||||
null -> {
|
null -> {
|
||||||
// No node means that the class was not subject for commonization.
|
// No node means that the class was not subject for commonization.
|
||||||
// - Either it is missing in certain targets at all => not commonized.
|
// - Either it is missing in certain targets at all => not commonized.
|
||||||
@@ -224,7 +224,7 @@ private fun commonizeTypeAlias(typeAliasId: CirEntityId, classifiers: CirKnownCl
|
|||||||
return SUCCESS_FROM_DEPENDENCY_LIBRARY
|
return SUCCESS_FROM_DEPENDENCY_LIBRARY
|
||||||
}
|
}
|
||||||
|
|
||||||
return when (val node = classifiers.commonized.typeAliasNode(typeAliasId)) {
|
return when (val node = classifiers.commonizedNodes.typeAliasNode(typeAliasId)) {
|
||||||
null -> {
|
null -> {
|
||||||
// No node means that the type alias was not subject for commonization. It is missing in some target(s) => not commonized.
|
// No node means that the type alias was not subject for commonization. It is missing in some target(s) => not commonized.
|
||||||
FAILURE_MISSING_IN_SOME_TARGET
|
FAILURE_MISSING_IN_SOME_TARGET
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ fun runCommonization(parameters: CommonizerParameters) {
|
|||||||
private fun mergeAndCommonize(storageManager: StorageManager, parameters: CommonizerParameters): CirTreeMergeResult {
|
private fun mergeAndCommonize(storageManager: StorageManager, parameters: CommonizerParameters): CirTreeMergeResult {
|
||||||
// build merged tree:
|
// build merged tree:
|
||||||
val classifiers = CirKnownClassifiers(
|
val classifiers = CirKnownClassifiers(
|
||||||
commonized = CirCommonizedClassifiers.default(),
|
commonizedNodes = CirCommonizedClassifierNodes.default(),
|
||||||
forwardDeclarations = CirForwardDeclarations.default(),
|
forwardDeclarations = CirForwardDeclarations.default(),
|
||||||
dependencies = mapOf(
|
dependencies = mapOf(
|
||||||
// for now, supply only common dependency libraries (ex: Kotlin stdlib)
|
// for now, supply only common dependency libraries (ex: Kotlin stdlib)
|
||||||
|
|||||||
+3
-3
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId
|
|||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.isUnderKotlinNativeSyntheticPackages
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.isUnderKotlinNativeSyntheticPackages
|
||||||
|
|
||||||
class CirKnownClassifiers(
|
class CirKnownClassifiers(
|
||||||
val commonized: CirCommonizedClassifiers,
|
val commonizedNodes: CirCommonizedClassifierNodes,
|
||||||
val forwardDeclarations: CirForwardDeclarations,
|
val forwardDeclarations: CirForwardDeclarations,
|
||||||
val dependencies: Map<CommonizerTarget, CirProvidedClassifiers>
|
val dependencies: Map<CommonizerTarget, CirProvidedClassifiers>
|
||||||
) {
|
) {
|
||||||
@@ -23,7 +23,7 @@ class CirKnownClassifiers(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** A set of all CIR nodes built for commonized classes and type aliases. */
|
/** A set of all CIR nodes built for commonized classes and type aliases. */
|
||||||
interface CirCommonizedClassifiers {
|
interface CirCommonizedClassifierNodes {
|
||||||
/* Accessors */
|
/* Accessors */
|
||||||
fun classNode(classId: CirEntityId): CirClassNode?
|
fun classNode(classId: CirEntityId): CirClassNode?
|
||||||
fun typeAliasNode(typeAliasId: CirEntityId): CirTypeAliasNode?
|
fun typeAliasNode(typeAliasId: CirEntityId): CirTypeAliasNode?
|
||||||
@@ -33,7 +33,7 @@ interface CirCommonizedClassifiers {
|
|||||||
fun addTypeAliasNode(typeAliasId: CirEntityId, node: CirTypeAliasNode)
|
fun addTypeAliasNode(typeAliasId: CirEntityId, node: CirTypeAliasNode)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun default() = object : CirCommonizedClassifiers {
|
fun default() = object : CirCommonizedClassifierNodes {
|
||||||
private val classNodes = THashMap<CirEntityId, CirClassNode>()
|
private val classNodes = THashMap<CirEntityId, CirClassNode>()
|
||||||
private val typeAliases = THashMap<CirEntityId, CirTypeAliasNode>()
|
private val typeAliases = THashMap<CirEntityId, CirTypeAliasNode>()
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -84,7 +84,7 @@ internal fun buildClassNode(
|
|||||||
recursionMarker = CirClassRecursionMarker,
|
recursionMarker = CirClassRecursionMarker,
|
||||||
nodeProducer = { targetDeclarations, commonDeclaration ->
|
nodeProducer = { targetDeclarations, commonDeclaration ->
|
||||||
CirClassNode(targetDeclarations, commonDeclaration).also {
|
CirClassNode(targetDeclarations, commonDeclaration).also {
|
||||||
classifiers.commonized.addClassNode(classId, it)
|
classifiers.commonizedNodes.addClassNode(classId, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -114,7 +114,7 @@ internal fun buildTypeAliasNode(
|
|||||||
recursionMarker = CirClassifierRecursionMarker,
|
recursionMarker = CirClassifierRecursionMarker,
|
||||||
nodeProducer = { targetDeclarations, commonDeclaration ->
|
nodeProducer = { targetDeclarations, commonDeclaration ->
|
||||||
CirTypeAliasNode(targetDeclarations, commonDeclaration).also {
|
CirTypeAliasNode(targetDeclarations, commonDeclaration).also {
|
||||||
classifiers.commonized.addTypeAliasNode(typeAliasId, it)
|
classifiers.commonizedNodes.addTypeAliasNode(typeAliasId, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
+3
-3
@@ -33,7 +33,7 @@ class TypeCommonizerTest : AbstractCommonizerTest<CirType, CirType>() {
|
|||||||
fun initialize() {
|
fun initialize() {
|
||||||
// reset cache
|
// reset cache
|
||||||
classifiers = CirKnownClassifiers(
|
classifiers = CirKnownClassifiers(
|
||||||
commonized = CirCommonizedClassifiers.default(),
|
commonizedNodes = CirCommonizedClassifierNodes.default(),
|
||||||
forwardDeclarations = CirForwardDeclarations.default(),
|
forwardDeclarations = CirForwardDeclarations.default(),
|
||||||
dependencies = mapOf(
|
dependencies = mapOf(
|
||||||
FAKE_SHARED_TARGET to object : CirProvidedClassifiers {
|
FAKE_SHARED_TARGET to object : CirProvidedClassifiers {
|
||||||
@@ -540,9 +540,9 @@ class TypeCommonizerTest : AbstractCommonizerTest<CirType, CirType>() {
|
|||||||
private val FAKE_SHARED_TARGET = SharedCommonizerTarget(setOf(LeafCommonizerTarget("a"), LeafCommonizerTarget("b")))
|
private val FAKE_SHARED_TARGET = SharedCommonizerTarget(setOf(LeafCommonizerTarget("a"), LeafCommonizerTarget("b")))
|
||||||
|
|
||||||
private fun CirKnownClassifiers.classNode(classId: CirEntityId, computation: () -> CirClassNode) =
|
private fun CirKnownClassifiers.classNode(classId: CirEntityId, computation: () -> CirClassNode) =
|
||||||
commonized.classNode(classId) ?: computation()
|
commonizedNodes.classNode(classId) ?: computation()
|
||||||
|
|
||||||
private fun CirKnownClassifiers.typeAliasNode(typeAliasId: CirEntityId, computation: () -> CirTypeAliasNode) =
|
private fun CirKnownClassifiers.typeAliasNode(typeAliasId: CirEntityId, computation: () -> CirTypeAliasNode) =
|
||||||
commonized.typeAliasNode(typeAliasId) ?: computation()
|
commonizedNodes.typeAliasNode(typeAliasId) ?: computation()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ private fun createPackageFragmentForClassifier(classifierFqName: FqName): Packag
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal val MOCK_CLASSIFIERS = CirKnownClassifiers(
|
internal val MOCK_CLASSIFIERS = CirKnownClassifiers(
|
||||||
commonized = object : CirCommonizedClassifiers {
|
commonizedNodes = object : CirCommonizedClassifierNodes {
|
||||||
private val MOCK_CLASS_NODE = CirClassNode(
|
private val MOCK_CLASS_NODE = CirClassNode(
|
||||||
CommonizedGroup(0),
|
CommonizedGroup(0),
|
||||||
LockBasedStorageManager.NO_LOCKS.createNullableLazyValue {
|
LockBasedStorageManager.NO_LOCKS.createNullableLazyValue {
|
||||||
|
|||||||
Reference in New Issue
Block a user