From 892512cb67586e8be8d803c2453436e4fef39deb Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Thu, 16 Sep 2021 14:34:35 +0200 Subject: [PATCH] [Commonizer] Remove unused/old typeAliasUtils ^KT-48288 --- .../kotlin/commonizer/core/typeAliasUtils.kt | 72 ------------------- 1 file changed, 72 deletions(-) delete mode 100644 native/commonizer/src/org/jetbrains/kotlin/commonizer/core/typeAliasUtils.kt diff --git a/native/commonizer/src/org/jetbrains/kotlin/commonizer/core/typeAliasUtils.kt b/native/commonizer/src/org/jetbrains/kotlin/commonizer/core/typeAliasUtils.kt deleted file mode 100644 index 295e53525a2..00000000000 --- a/native/commonizer/src/org/jetbrains/kotlin/commonizer/core/typeAliasUtils.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.commonizer.core - -import org.jetbrains.kotlin.commonizer.cir.CirClassOrTypeAliasType -import org.jetbrains.kotlin.commonizer.cir.CirClassType -import org.jetbrains.kotlin.commonizer.cir.CirTypeAliasType -import org.jetbrains.kotlin.commonizer.cir.CirTypeProjection -import org.jetbrains.kotlin.commonizer.mergedtree.CirKnownClassifiers - -internal tailrec fun computeSuitableUnderlyingType( - classifiers: CirKnownClassifiers, - typeCommonizer: TypeCommonizer, - underlyingType: CirClassOrTypeAliasType -): CirClassOrTypeAliasType? { - return when (underlyingType) { - is CirClassType -> underlyingType.withCommonizedArguments(typeCommonizer) - is CirTypeAliasType -> - if (classifiers.commonDependencies.hasClassifier(underlyingType.classifierId) || - classifiers.commonizedNodes.typeAliasNode(underlyingType.classifierId)?.commonDeclaration?.invoke() != null - ) underlyingType.withCommonizedArguments(typeCommonizer) - else computeSuitableUnderlyingType(classifiers, typeCommonizer, underlyingType.underlyingType) - } -} - -private fun CirClassType.withCommonizedArguments(typeCommonizer: TypeCommonizer): CirClassType? { - val existingArguments = arguments - val newArguments = existingArguments.toCommonizedArguments(typeCommonizer) ?: return null - - val existingOuterType = outerType - val newOuterType = existingOuterType?.let { it.withCommonizedArguments(typeCommonizer) ?: return null } - - return if (newArguments !== existingArguments || newOuterType !== existingOuterType) - CirClassType.createInterned( - classId = classifierId, - outerType = newOuterType, - visibility = visibility, - arguments = newArguments, - isMarkedNullable = isMarkedNullable - ) - else - this -} - -private fun CirTypeAliasType.withCommonizedArguments(typeCommonizer: TypeCommonizer): CirTypeAliasType? { - val existingArguments = arguments - val newArguments = existingArguments.toCommonizedArguments(typeCommonizer) ?: return null - - val existingUnderlyingType = underlyingType - val newUnderlyingType = when (existingUnderlyingType) { - is CirClassType -> existingUnderlyingType.withCommonizedArguments(typeCommonizer) - is CirTypeAliasType -> existingUnderlyingType.withCommonizedArguments(typeCommonizer) - } ?: return null - - return if (newArguments !== existingArguments || newUnderlyingType !== existingUnderlyingType) - CirTypeAliasType.createInterned( - typeAliasId = classifierId, - underlyingType = newUnderlyingType, - arguments = newArguments, - isMarkedNullable = isMarkedNullable - ) - else - this -} - -@Suppress("NOTHING_TO_INLINE") -private inline fun List.toCommonizedArguments(typeCommonizer: TypeCommonizer): List? = - if (isEmpty()) this - else TypeArgumentListCommonizer(typeCommonizer).let { if (it.commonizeWith(this)) it.result else null }