[Commonizer] Rename: MetadataBuilder -> CirTreeSeralizer
This commit is contained in:
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.descriptors.commonizer.core.CommonizationVisitor
|
|||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.*
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.*
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirNode.Companion.dimension
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirNode.Companion.dimension
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirTreeMerger.CirTreeMergeResult
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirTreeMerger.CirTreeMergeResult
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.metadata.MetadataBuilder
|
import org.jetbrains.kotlin.descriptors.commonizer.metadata.CirTreeSerializer
|
||||||
import org.jetbrains.kotlin.library.SerializedMetadata
|
import org.jetbrains.kotlin.library.SerializedMetadata
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
@@ -59,7 +59,7 @@ private fun serializeTarget(mergeResult: CirTreeMergeResult, targetIndex: Int, p
|
|||||||
val mergedTree = mergeResult.root
|
val mergedTree = mergeResult.root
|
||||||
val target = mergedTree.getTarget(targetIndex)
|
val target = mergedTree.getTarget(targetIndex)
|
||||||
|
|
||||||
MetadataBuilder.build(mergedTree, targetIndex, parameters.statsCollector) { metadataModule ->
|
CirTreeSerializer.serializeSingleTarget(mergedTree, targetIndex, parameters.statsCollector) { metadataModule ->
|
||||||
val libraryName = metadataModule.name
|
val libraryName = metadataModule.name
|
||||||
val serializedMetadata = with(metadataModule.write(KLIB_FRAGMENT_WRITE_STRATEGY)) {
|
val serializedMetadata = with(metadataModule.write(KLIB_FRAGMENT_WRITE_STRATEGY)) {
|
||||||
SerializedMetadata(header, fragments, fragmentNames)
|
SerializedMetadata(header, fragments, fragmentNames)
|
||||||
|
|||||||
+32
-32
@@ -17,32 +17,32 @@ import org.jetbrains.kotlin.descriptors.commonizer.stats.StatsCollector.StatsKey
|
|||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.DEFAULT_CONSTRUCTOR_NAME
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.DEFAULT_CONSTRUCTOR_NAME
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.firstNonNull
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.firstNonNull
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.metadata.MetadataBuildingVisitorContext.Path
|
import org.jetbrains.kotlin.descriptors.commonizer.metadata.CirTreeSerializationContext.Path
|
||||||
|
|
||||||
internal object MetadataBuilder {
|
object CirTreeSerializer {
|
||||||
fun build(
|
fun serializeSingleTarget(
|
||||||
node: CirRootNode,
|
node: CirRootNode,
|
||||||
targetIndex: Int,
|
targetIndex: Int,
|
||||||
statsCollector: StatsCollector?,
|
statsCollector: StatsCollector?,
|
||||||
moduleConsumer: (KlibModuleMetadata) -> Unit
|
moduleConsumer: (KlibModuleMetadata) -> Unit
|
||||||
) {
|
) {
|
||||||
node.accept(
|
node.accept(
|
||||||
MetadataBuildingVisitor(statsCollector, moduleConsumer),
|
CirTreeSerializationVisitor(statsCollector, moduleConsumer),
|
||||||
MetadataBuildingVisitorContext.rootContext(node, targetIndex)
|
CirTreeSerializationContext.rootContext(node, targetIndex)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE")
|
@Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE")
|
||||||
private class MetadataBuildingVisitor(
|
private class CirTreeSerializationVisitor(
|
||||||
private val statsCollector: StatsCollector?,
|
private val statsCollector: StatsCollector?,
|
||||||
private val moduleConsumer: (KlibModuleMetadata) -> Unit
|
private val moduleConsumer: (KlibModuleMetadata) -> Unit
|
||||||
) : CirNodeVisitor<MetadataBuildingVisitorContext, Any?> {
|
) : CirNodeVisitor<CirTreeSerializationContext, Any?> {
|
||||||
private val classConsumer = ClassConsumer()
|
private val classConsumer = ClassConsumer()
|
||||||
|
|
||||||
override fun visitRootNode(
|
override fun visitRootNode(
|
||||||
node: CirRootNode,
|
node: CirRootNode,
|
||||||
rootContext: MetadataBuildingVisitorContext
|
rootContext: CirTreeSerializationContext
|
||||||
) {
|
) {
|
||||||
node.modules.forEach { (moduleName, moduleNode) ->
|
node.modules.forEach { (moduleName, moduleNode) ->
|
||||||
val moduleContext = rootContext.moduleContext(moduleName)
|
val moduleContext = rootContext.moduleContext(moduleName)
|
||||||
@@ -56,7 +56,7 @@ private class MetadataBuildingVisitor(
|
|||||||
|
|
||||||
override fun visitModuleNode(
|
override fun visitModuleNode(
|
||||||
node: CirModuleNode,
|
node: CirModuleNode,
|
||||||
moduleContext: MetadataBuildingVisitorContext
|
moduleContext: CirTreeSerializationContext
|
||||||
): KlibModuleMetadata? {
|
): KlibModuleMetadata? {
|
||||||
val cirModule = moduleContext.get<CirModule>(node) ?: return null
|
val cirModule = moduleContext.get<CirModule>(node) ?: return null
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ private class MetadataBuildingVisitor(
|
|||||||
|
|
||||||
override fun visitPackageNode(
|
override fun visitPackageNode(
|
||||||
node: CirPackageNode,
|
node: CirPackageNode,
|
||||||
packageContext: MetadataBuildingVisitorContext
|
packageContext: CirTreeSerializationContext
|
||||||
): KmModuleFragment? {
|
): KmModuleFragment? {
|
||||||
val cirPackage = packageContext.get<CirPackage>(node) ?: return null
|
val cirPackage = packageContext.get<CirPackage>(node) ?: return null
|
||||||
|
|
||||||
@@ -127,21 +127,21 @@ private class MetadataBuildingVisitor(
|
|||||||
|
|
||||||
override fun visitPropertyNode(
|
override fun visitPropertyNode(
|
||||||
node: CirPropertyNode,
|
node: CirPropertyNode,
|
||||||
propertyContext: MetadataBuildingVisitorContext
|
propertyContext: CirTreeSerializationContext
|
||||||
): KmProperty? {
|
): KmProperty? {
|
||||||
return propertyContext.get<CirProperty>(node)?.buildProperty(propertyContext)
|
return propertyContext.get<CirProperty>(node)?.buildProperty(propertyContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitFunctionNode(
|
override fun visitFunctionNode(
|
||||||
node: CirFunctionNode,
|
node: CirFunctionNode,
|
||||||
functionContext: MetadataBuildingVisitorContext
|
functionContext: CirTreeSerializationContext
|
||||||
): KmFunction? {
|
): KmFunction? {
|
||||||
return functionContext.get<CirFunction>(node)?.buildFunction(functionContext)
|
return functionContext.get<CirFunction>(node)?.buildFunction(functionContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitClassNode(
|
override fun visitClassNode(
|
||||||
node: CirClassNode,
|
node: CirClassNode,
|
||||||
classContext: MetadataBuildingVisitorContext
|
classContext: CirTreeSerializationContext
|
||||||
): KmClass? {
|
): KmClass? {
|
||||||
val cirClass = classContext.get<CirClass>(node) ?: return null
|
val cirClass = classContext.get<CirClass>(node) ?: return null
|
||||||
val classTypeParametersCount = cirClass.typeParameters.size
|
val classTypeParametersCount = cirClass.typeParameters.size
|
||||||
@@ -181,14 +181,14 @@ private class MetadataBuildingVisitor(
|
|||||||
|
|
||||||
override fun visitClassConstructorNode(
|
override fun visitClassConstructorNode(
|
||||||
node: CirClassConstructorNode,
|
node: CirClassConstructorNode,
|
||||||
constructorContext: MetadataBuildingVisitorContext
|
constructorContext: CirTreeSerializationContext
|
||||||
): KmConstructor? {
|
): KmConstructor? {
|
||||||
return constructorContext.get<CirClassConstructor>(node)?.buildClassConstructor(constructorContext)
|
return constructorContext.get<CirClassConstructor>(node)?.buildClassConstructor(constructorContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitTypeAliasNode(
|
override fun visitTypeAliasNode(
|
||||||
node: CirTypeAliasNode,
|
node: CirTypeAliasNode,
|
||||||
typeAliasContext: MetadataBuildingVisitorContext
|
typeAliasContext: CirTreeSerializationContext
|
||||||
): Any? {
|
): Any? {
|
||||||
val cirClassifier = typeAliasContext.get<CirClassifier>(node) ?: return null
|
val cirClassifier = typeAliasContext.get<CirClassifier>(node) ?: return null
|
||||||
|
|
||||||
@@ -204,14 +204,14 @@ private class MetadataBuildingVisitor(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private fun StatsCollector.logModule(
|
private fun StatsCollector.logModule(
|
||||||
moduleContext: MetadataBuildingVisitorContext
|
moduleContext: CirTreeSerializationContext
|
||||||
) = logDeclaration(moduleContext.targetIndex) {
|
) = logDeclaration(moduleContext.targetIndex) {
|
||||||
StatsKey(moduleContext.currentPath.toString(), DeclarationType.MODULE)
|
StatsKey(moduleContext.currentPath.toString(), DeclarationType.MODULE)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun StatsCollector.logClass(
|
private fun StatsCollector.logClass(
|
||||||
clazz: KmClass,
|
clazz: KmClass,
|
||||||
classContext: MetadataBuildingVisitorContext
|
classContext: CirTreeSerializationContext
|
||||||
) = logDeclaration(classContext.targetIndex) {
|
) = logDeclaration(classContext.targetIndex) {
|
||||||
val declarationType = when {
|
val declarationType = when {
|
||||||
Flag.Class.IS_ENUM_CLASS(clazz.flags) -> DeclarationType.ENUM_CLASS
|
Flag.Class.IS_ENUM_CLASS(clazz.flags) -> DeclarationType.ENUM_CLASS
|
||||||
@@ -231,13 +231,13 @@ private class MetadataBuildingVisitor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun StatsCollector.logTypeAlias(
|
private fun StatsCollector.logTypeAlias(
|
||||||
typeAliasContext: MetadataBuildingVisitorContext
|
typeAliasContext: CirTreeSerializationContext
|
||||||
) = logDeclaration(typeAliasContext.targetIndex) {
|
) = logDeclaration(typeAliasContext.targetIndex) {
|
||||||
StatsKey(typeAliasContext.currentPath.toString(), DeclarationType.TYPE_ALIAS)
|
StatsKey(typeAliasContext.currentPath.toString(), DeclarationType.TYPE_ALIAS)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun StatsCollector.logProperty(
|
private fun StatsCollector.logProperty(
|
||||||
propertyContext: MetadataBuildingVisitorContext,
|
propertyContext: CirTreeSerializationContext,
|
||||||
propertyKey: PropertyApproximationKey,
|
propertyKey: PropertyApproximationKey,
|
||||||
propertyNode: CirPropertyNode
|
propertyNode: CirPropertyNode
|
||||||
) = logDeclaration(propertyContext.targetIndex) {
|
) = logDeclaration(propertyContext.targetIndex) {
|
||||||
@@ -258,7 +258,7 @@ private class MetadataBuildingVisitor(
|
|||||||
|
|
||||||
private fun StatsCollector.logFunction(
|
private fun StatsCollector.logFunction(
|
||||||
function: KmFunction,
|
function: KmFunction,
|
||||||
functionContext: MetadataBuildingVisitorContext,
|
functionContext: CirTreeSerializationContext,
|
||||||
functionKey: FunctionApproximationKey
|
functionKey: FunctionApproximationKey
|
||||||
) = logDeclaration(functionContext.targetIndex) {
|
) = logDeclaration(functionContext.targetIndex) {
|
||||||
val declarationType = when {
|
val declarationType = when {
|
||||||
@@ -277,7 +277,7 @@ private class MetadataBuildingVisitor(
|
|||||||
|
|
||||||
private fun StatsCollector.logClassConstructor(
|
private fun StatsCollector.logClassConstructor(
|
||||||
constructor: KmConstructor,
|
constructor: KmConstructor,
|
||||||
constructorContext: MetadataBuildingVisitorContext,
|
constructorContext: CirTreeSerializationContext,
|
||||||
constructorKey: ConstructorApproximationKey
|
constructorKey: ConstructorApproximationKey
|
||||||
) = logDeclaration(constructorContext.targetIndex) {
|
) = logDeclaration(constructorContext.targetIndex) {
|
||||||
StatsKey(
|
StatsKey(
|
||||||
@@ -291,7 +291,7 @@ private class MetadataBuildingVisitor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal data class MetadataBuildingVisitorContext(
|
internal data class CirTreeSerializationContext(
|
||||||
val targetIndex: Int,
|
val targetIndex: Int,
|
||||||
val target: CommonizerTarget,
|
val target: CommonizerTarget,
|
||||||
val isCommon: Boolean,
|
val isCommon: Boolean,
|
||||||
@@ -327,10 +327,10 @@ internal data class MetadataBuildingVisitorContext(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun moduleContext(moduleName: CirName): MetadataBuildingVisitorContext {
|
fun moduleContext(moduleName: CirName): CirTreeSerializationContext {
|
||||||
check(currentPath is Path.Empty)
|
check(currentPath is Path.Empty)
|
||||||
|
|
||||||
return MetadataBuildingVisitorContext(
|
return CirTreeSerializationContext(
|
||||||
targetIndex = targetIndex,
|
targetIndex = targetIndex,
|
||||||
target = target,
|
target = target,
|
||||||
isCommon = isCommon,
|
isCommon = isCommon,
|
||||||
@@ -339,10 +339,10 @@ internal data class MetadataBuildingVisitorContext(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun packageContext(packageName: CirPackageName): MetadataBuildingVisitorContext {
|
fun packageContext(packageName: CirPackageName): CirTreeSerializationContext {
|
||||||
check(currentPath is Path.Module)
|
check(currentPath is Path.Module)
|
||||||
|
|
||||||
return MetadataBuildingVisitorContext(
|
return CirTreeSerializationContext(
|
||||||
targetIndex = targetIndex,
|
targetIndex = targetIndex,
|
||||||
target = target,
|
target = target,
|
||||||
isCommon = isCommon,
|
isCommon = isCommon,
|
||||||
@@ -354,7 +354,7 @@ internal data class MetadataBuildingVisitorContext(
|
|||||||
fun classifierContext(
|
fun classifierContext(
|
||||||
classifierName: CirName,
|
classifierName: CirName,
|
||||||
outerClassTypeParametersCount: Int = 0
|
outerClassTypeParametersCount: Int = 0
|
||||||
): MetadataBuildingVisitorContext {
|
): CirTreeSerializationContext {
|
||||||
val newPath = when (currentPath) {
|
val newPath = when (currentPath) {
|
||||||
is Path.Package -> {
|
is Path.Package -> {
|
||||||
check(outerClassTypeParametersCount == 0)
|
check(outerClassTypeParametersCount == 0)
|
||||||
@@ -367,7 +367,7 @@ internal data class MetadataBuildingVisitorContext(
|
|||||||
else -> error("Illegal state")
|
else -> error("Illegal state")
|
||||||
}
|
}
|
||||||
|
|
||||||
return MetadataBuildingVisitorContext(
|
return CirTreeSerializationContext(
|
||||||
targetIndex = targetIndex,
|
targetIndex = targetIndex,
|
||||||
target = target,
|
target = target,
|
||||||
isCommon = isCommon,
|
isCommon = isCommon,
|
||||||
@@ -379,7 +379,7 @@ internal data class MetadataBuildingVisitorContext(
|
|||||||
fun callableMemberContext(
|
fun callableMemberContext(
|
||||||
memberName: CirName,
|
memberName: CirName,
|
||||||
ownerClassTypeParametersCount: Int = 0
|
ownerClassTypeParametersCount: Int = 0
|
||||||
): MetadataBuildingVisitorContext {
|
): CirTreeSerializationContext {
|
||||||
val newPath = when (currentPath) {
|
val newPath = when (currentPath) {
|
||||||
is Path.Package -> {
|
is Path.Package -> {
|
||||||
check(ownerClassTypeParametersCount == 0)
|
check(ownerClassTypeParametersCount == 0)
|
||||||
@@ -392,7 +392,7 @@ internal data class MetadataBuildingVisitorContext(
|
|||||||
else -> error("Illegal state")
|
else -> error("Illegal state")
|
||||||
}
|
}
|
||||||
|
|
||||||
return MetadataBuildingVisitorContext(
|
return CirTreeSerializationContext(
|
||||||
targetIndex = targetIndex,
|
targetIndex = targetIndex,
|
||||||
target = target,
|
target = target,
|
||||||
isCommon = isCommon,
|
isCommon = isCommon,
|
||||||
@@ -414,8 +414,8 @@ internal data class MetadataBuildingVisitorContext(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun rootContext(rootNode: CirRootNode, targetIndex: Int): MetadataBuildingVisitorContext =
|
fun rootContext(rootNode: CirRootNode, targetIndex: Int): CirTreeSerializationContext =
|
||||||
MetadataBuildingVisitorContext(
|
CirTreeSerializationContext(
|
||||||
targetIndex = targetIndex,
|
targetIndex = targetIndex,
|
||||||
target = rootNode.getTarget(targetIndex),
|
target = rootNode.getTarget(targetIndex),
|
||||||
isCommon = rootNode.indexOfCommon == targetIndex,
|
isCommon = rootNode.indexOfCommon == targetIndex,
|
||||||
+13
-13
@@ -70,7 +70,7 @@ internal fun addEmptyFragments(fragments: MutableCollection<KmModuleFragment>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun CirClass.buildClass(
|
internal fun CirClass.buildClass(
|
||||||
context: MetadataBuildingVisitorContext,
|
context: CirTreeSerializationContext,
|
||||||
className: ClassName,
|
className: ClassName,
|
||||||
directNestedClasses: Collection<KmClass>,
|
directNestedClasses: Collection<KmClass>,
|
||||||
nestedConstructors: Collection<KmConstructor>,
|
nestedConstructors: Collection<KmConstructor>,
|
||||||
@@ -125,7 +125,7 @@ internal fun linkSealedClassesWithSubclasses(packageName: CirPackageName, classC
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun CirClassConstructor.buildClassConstructor(
|
internal fun CirClassConstructor.buildClassConstructor(
|
||||||
context: MetadataBuildingVisitorContext
|
context: CirTreeSerializationContext
|
||||||
): KmConstructor = KmConstructor(
|
): KmConstructor = KmConstructor(
|
||||||
flags = classConstructorFlags()
|
flags = classConstructorFlags()
|
||||||
).also { constructor ->
|
).also { constructor ->
|
||||||
@@ -135,7 +135,7 @@ internal fun CirClassConstructor.buildClassConstructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun CirTypeAlias.buildTypeAlias(
|
internal fun CirTypeAlias.buildTypeAlias(
|
||||||
context: MetadataBuildingVisitorContext
|
context: CirTreeSerializationContext
|
||||||
): KmTypeAlias = KmTypeAlias(
|
): KmTypeAlias = KmTypeAlias(
|
||||||
flags = typeAliasFlags(),
|
flags = typeAliasFlags(),
|
||||||
name = name.name
|
name = name.name
|
||||||
@@ -147,7 +147,7 @@ internal fun CirTypeAlias.buildTypeAlias(
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun CirProperty.buildProperty(
|
internal fun CirProperty.buildProperty(
|
||||||
context: MetadataBuildingVisitorContext,
|
context: CirTreeSerializationContext,
|
||||||
): KmProperty = KmProperty(
|
): KmProperty = KmProperty(
|
||||||
flags = propertyFlags(isExpect = context.isCommon && !isLiftedUp),
|
flags = propertyFlags(isExpect = context.isCommon && !isLiftedUp),
|
||||||
name = name.name,
|
name = name.name,
|
||||||
@@ -179,7 +179,7 @@ internal fun CirProperty.buildProperty(
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun CirFunction.buildFunction(
|
internal fun CirFunction.buildFunction(
|
||||||
context: MetadataBuildingVisitorContext,
|
context: CirTreeSerializationContext,
|
||||||
): KmFunction = KmFunction(
|
): KmFunction = KmFunction(
|
||||||
flags = functionFlags(isExpect = context.isCommon && kind != CallableMemberDescriptor.Kind.SYNTHESIZED),
|
flags = functionFlags(isExpect = context.isCommon && kind != CallableMemberDescriptor.Kind.SYNTHESIZED),
|
||||||
name = name.name
|
name = name.name
|
||||||
@@ -239,7 +239,7 @@ private fun CirConstantValue<*>.buildAnnotationArgument(): KmAnnotationArgument<
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun CirValueParameter.buildValueParameter(
|
private fun CirValueParameter.buildValueParameter(
|
||||||
context: MetadataBuildingVisitorContext
|
context: CirTreeSerializationContext
|
||||||
): KmValueParameter = KmValueParameter(
|
): KmValueParameter = KmValueParameter(
|
||||||
flags = valueParameterFlags(),
|
flags = valueParameterFlags(),
|
||||||
name = name.name
|
name = name.name
|
||||||
@@ -252,7 +252,7 @@ private fun CirValueParameter.buildValueParameter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun List<CirTypeParameter>.buildTypeParameters(
|
private fun List<CirTypeParameter>.buildTypeParameters(
|
||||||
context: MetadataBuildingVisitorContext,
|
context: CirTreeSerializationContext,
|
||||||
output: MutableList<KmTypeParameter>
|
output: MutableList<KmTypeParameter>
|
||||||
) {
|
) {
|
||||||
mapIndexedTo(output) { index, cirTypeParameter ->
|
mapIndexedTo(output) { index, cirTypeParameter ->
|
||||||
@@ -269,7 +269,7 @@ private fun List<CirTypeParameter>.buildTypeParameters(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun CirType.buildType(
|
private fun CirType.buildType(
|
||||||
context: MetadataBuildingVisitorContext,
|
context: CirTreeSerializationContext,
|
||||||
expansion: TypeAliasExpansion = FOR_TOP_LEVEL_TYPE
|
expansion: TypeAliasExpansion = FOR_TOP_LEVEL_TYPE
|
||||||
): KmType = when (this) {
|
): KmType = when (this) {
|
||||||
is CirClassType -> buildType(context, expansion)
|
is CirClassType -> buildType(context, expansion)
|
||||||
@@ -291,7 +291,7 @@ private fun CirTypeParameterType.buildType(): KmType =
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun CirClassType.buildType(
|
private fun CirClassType.buildType(
|
||||||
context: MetadataBuildingVisitorContext,
|
context: CirTreeSerializationContext,
|
||||||
expansion: TypeAliasExpansion
|
expansion: TypeAliasExpansion
|
||||||
): KmType = KmType(typeFlags()).also { type ->
|
): KmType = KmType(typeFlags()).also { type ->
|
||||||
type.classifier = KmClassifier.Class(classifierId.toString())
|
type.classifier = KmClassifier.Class(classifierId.toString())
|
||||||
@@ -300,7 +300,7 @@ private fun CirClassType.buildType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun CirTypeAliasType.buildType(
|
private fun CirTypeAliasType.buildType(
|
||||||
context: MetadataBuildingVisitorContext,
|
context: CirTreeSerializationContext,
|
||||||
expansion: TypeAliasExpansion
|
expansion: TypeAliasExpansion
|
||||||
): KmType = when (expansion) {
|
): KmType = when (expansion) {
|
||||||
ONLY_ABBREVIATIONS -> buildAbbreviationType(context, expansion)
|
ONLY_ABBREVIATIONS -> buildAbbreviationType(context, expansion)
|
||||||
@@ -314,7 +314,7 @@ private fun CirTypeAliasType.buildType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun CirTypeAliasType.buildAbbreviationType(
|
private fun CirTypeAliasType.buildAbbreviationType(
|
||||||
context: MetadataBuildingVisitorContext,
|
context: CirTreeSerializationContext,
|
||||||
expansion: TypeAliasExpansion
|
expansion: TypeAliasExpansion
|
||||||
): KmType {
|
): KmType {
|
||||||
val abbreviationType = KmType(typeFlags())
|
val abbreviationType = KmType(typeFlags())
|
||||||
@@ -325,7 +325,7 @@ private fun CirTypeAliasType.buildAbbreviationType(
|
|||||||
|
|
||||||
@Suppress("UnnecessaryVariable")
|
@Suppress("UnnecessaryVariable")
|
||||||
private fun CirTypeAliasType.buildExpandedType(
|
private fun CirTypeAliasType.buildExpandedType(
|
||||||
context: MetadataBuildingVisitorContext,
|
context: CirTreeSerializationContext,
|
||||||
expansion: TypeAliasExpansion
|
expansion: TypeAliasExpansion
|
||||||
): KmType {
|
): KmType {
|
||||||
val cirExpandedType = computeExpandedType(underlyingType)
|
val cirExpandedType = computeExpandedType(underlyingType)
|
||||||
@@ -334,7 +334,7 @@ private fun CirTypeAliasType.buildExpandedType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun CirTypeProjection.buildArgument(
|
private fun CirTypeProjection.buildArgument(
|
||||||
context: MetadataBuildingVisitorContext,
|
context: CirTreeSerializationContext,
|
||||||
expansion: TypeAliasExpansion
|
expansion: TypeAliasExpansion
|
||||||
): KmTypeProjection {
|
): KmTypeProjection {
|
||||||
val effectiveExpansion = if (expansion == FOR_TOP_LEVEL_TYPE) FOR_NESTED_TYPE else expansion
|
val effectiveExpansion = if (expansion == FOR_TOP_LEVEL_TYPE) FOR_NESTED_TYPE else expansion
|
||||||
|
|||||||
Reference in New Issue
Block a user