[Commonizer] Drop support of descriptors, part 2
This commit is contained in:
+2
-34
@@ -10,48 +10,16 @@ import kotlinx.metadata.Flag
|
||||
import kotlinx.metadata.Flags
|
||||
import kotlinx.metadata.KmAnnotation
|
||||
import kotlinx.metadata.KmAnnotationArgument
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirAnnotationImpl
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirProvided
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.*
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.Interner
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.compact
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.constants.AnnotationValue
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.compactMap
|
||||
|
||||
object CirAnnotationFactory {
|
||||
private val interner = Interner<CirAnnotation>()
|
||||
|
||||
fun create(source: AnnotationDescriptor): CirAnnotation {
|
||||
val type = CirTypeFactory.create(source.type) as CirClassType
|
||||
|
||||
val allValueArguments: Map<Name, ConstantValue<*>> = source.allValueArguments
|
||||
if (allValueArguments.isEmpty())
|
||||
return create(type = type, constantValueArguments = emptyMap(), annotationValueArguments = emptyMap())
|
||||
|
||||
val constantValueArguments: MutableMap<CirName, CirConstantValue<*>> = THashMap(allValueArguments.size)
|
||||
val annotationValueArguments: MutableMap<CirName, CirAnnotation> = THashMap(allValueArguments.size)
|
||||
|
||||
allValueArguments.forEach { (name, constantValue) ->
|
||||
val cirName = CirName.create(name)
|
||||
if (constantValue is AnnotationValue)
|
||||
annotationValueArguments[cirName] = create(source = constantValue.value)
|
||||
else
|
||||
constantValueArguments[cirName] = CirConstantValueFactory.createSafely(
|
||||
constantValue = constantValue,
|
||||
constantName = cirName,
|
||||
owner = source,
|
||||
)
|
||||
}
|
||||
|
||||
return create(
|
||||
type = type,
|
||||
constantValueArguments = constantValueArguments.compact(),
|
||||
annotationValueArguments = annotationValueArguments.compact()
|
||||
)
|
||||
}
|
||||
|
||||
fun createAnnotations(flags: Flags, typeResolver: CirTypeResolver, annotations: () -> List<KmAnnotation>): List<CirAnnotation> {
|
||||
return if (!Flag.Common.HAS_ANNOTATIONS(flags))
|
||||
emptyList()
|
||||
|
||||
+4
-19
@@ -9,7 +9,10 @@ import kotlinx.metadata.Flag
|
||||
import kotlinx.metadata.KmAnnotation
|
||||
import kotlinx.metadata.KmClass
|
||||
import kotlinx.metadata.klib.annotations
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirClassImpl
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.metadata.decodeClassKind
|
||||
@@ -17,26 +20,8 @@ import org.jetbrains.kotlin.descriptors.commonizer.metadata.decodeModality
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.metadata.decodeVisibility
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.compactMap
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.filteredSupertypes
|
||||
import org.jetbrains.kotlin.resolve.isInlineClass
|
||||
|
||||
object CirClassFactory {
|
||||
fun create(source: ClassDescriptor): CirClass = create(
|
||||
annotations = source.annotations.compactMap(CirAnnotationFactory::create),
|
||||
name = CirName.create(source.name),
|
||||
typeParameters = source.declaredTypeParameters.compactMap(CirTypeParameterFactory::create),
|
||||
visibility = source.visibility,
|
||||
modality = source.modality,
|
||||
kind = source.kind,
|
||||
companion = source.companionObjectDescriptor?.name?.let(CirName::create),
|
||||
isCompanion = source.isCompanionObject,
|
||||
isData = source.isData,
|
||||
isInline = source.isInlineClass(),
|
||||
isInner = source.isInner,
|
||||
isExternal = source.isExternal
|
||||
).apply {
|
||||
setSupertypes(source.filteredSupertypes.compactMap { CirTypeFactory.create(it) })
|
||||
}
|
||||
|
||||
fun create(name: CirName, source: KmClass, typeResolver: CirTypeResolver): CirClass = create(
|
||||
annotations = CirAnnotationFactory.createAnnotations(source.flags, typeResolver, source::annotations),
|
||||
name = name,
|
||||
|
||||
-50
@@ -10,58 +10,8 @@ import org.jetbrains.kotlin.descriptors.commonizer.cir.CirConstantValue
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.compactMapIndexed
|
||||
import org.jetbrains.kotlin.resolve.constants.*
|
||||
|
||||
object CirConstantValueFactory {
|
||||
fun createSafely(
|
||||
constantValue: ConstantValue<*>,
|
||||
constantName: CirName? = null,
|
||||
owner: Any,
|
||||
): CirConstantValue<*> = createSafely(
|
||||
constantValue = constantValue,
|
||||
location = { "${owner::class.java}, $owner" + constantName?.toString()?.let { "[$it]" } }
|
||||
)
|
||||
|
||||
private fun createSafely(
|
||||
constantValue: ConstantValue<*>,
|
||||
location: () -> String
|
||||
): CirConstantValue<*> = when (constantValue) {
|
||||
is NullValue -> CirConstantValue.NullValue
|
||||
|
||||
is StringValue -> CirConstantValue.StringValue(constantValue.value)
|
||||
is CharValue -> CirConstantValue.CharValue(constantValue.value)
|
||||
|
||||
is ByteValue -> CirConstantValue.ByteValue(constantValue.value)
|
||||
is ShortValue -> CirConstantValue.ShortValue(constantValue.value)
|
||||
is IntValue -> CirConstantValue.IntValue(constantValue.value)
|
||||
is LongValue -> CirConstantValue.LongValue(constantValue.value)
|
||||
|
||||
is UByteValue -> CirConstantValue.UByteValue(constantValue.value)
|
||||
is UShortValue -> CirConstantValue.UShortValue(constantValue.value)
|
||||
is UIntValue -> CirConstantValue.UIntValue(constantValue.value)
|
||||
is ULongValue -> CirConstantValue.ULongValue(constantValue.value)
|
||||
|
||||
is FloatValue -> CirConstantValue.FloatValue(constantValue.value)
|
||||
is DoubleValue -> CirConstantValue.DoubleValue(constantValue.value)
|
||||
is BooleanValue -> CirConstantValue.BooleanValue(constantValue.value)
|
||||
|
||||
is EnumValue -> CirConstantValue.EnumValue(
|
||||
CirEntityId.create(constantValue.enumClassId),
|
||||
CirName.create(constantValue.enumEntryName)
|
||||
)
|
||||
|
||||
is ArrayValue -> CirConstantValue.ArrayValue(
|
||||
constantValue.value.compactMapIndexed { index, innerConstantValue ->
|
||||
createSafely(
|
||||
constantValue = innerConstantValue,
|
||||
location = { "${location()}[$index]" }
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
else -> error("Unsupported const value type: ${constantValue::class.java}, $constantValue at ${location()}")
|
||||
}
|
||||
|
||||
fun createSafely(
|
||||
constantValue: KmAnnotationArgument<*>?,
|
||||
constantName: CirName? = null,
|
||||
|
||||
-15
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.descriptors.commonizer.cir.factory
|
||||
|
||||
import kotlinx.metadata.KmTypeAlias
|
||||
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirTypeAliasImpl
|
||||
@@ -14,20 +13,6 @@ import org.jetbrains.kotlin.descriptors.commonizer.metadata.decodeVisibility
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.compactMap
|
||||
|
||||
object CirTypeAliasFactory {
|
||||
fun create(source: TypeAliasDescriptor): CirTypeAlias {
|
||||
val underlyingType = CirTypeFactory.create(source.underlyingType) as CirClassOrTypeAliasType
|
||||
val expandedType = CirTypeFactory.unabbreviate(underlyingType)
|
||||
|
||||
return create(
|
||||
annotations = source.annotations.compactMap(CirAnnotationFactory::create),
|
||||
name = CirName.create(source.name),
|
||||
typeParameters = source.declaredTypeParameters.compactMap(CirTypeParameterFactory::create),
|
||||
visibility = source.visibility,
|
||||
underlyingType = underlyingType,
|
||||
expandedType = expandedType
|
||||
)
|
||||
}
|
||||
|
||||
fun create(name: CirName, source: KmTypeAlias, typeResolver: CirTypeResolver): CirTypeAlias {
|
||||
val underlyingType = CirTypeFactory.create(source.underlyingType, typeResolver) as CirClassOrTypeAliasType
|
||||
val expandedType = CirTypeFactory.unabbreviate(underlyingType)
|
||||
|
||||
+6
-118
@@ -7,17 +7,17 @@ package org.jetbrains.kotlin.descriptors.commonizer.cir.factory
|
||||
|
||||
import gnu.trove.TIntObjectHashMap
|
||||
import kotlinx.metadata.*
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirClassTypeImpl
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirTypeAliasTypeImpl
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.core.computeExpandedType
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirProvided
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirProvidedClassifiers
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.TypeParameterResolver
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.core.computeExpandedType
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.*
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
object CirTypeFactory {
|
||||
object StandardTypes {
|
||||
@@ -84,58 +84,6 @@ object CirTypeFactory {
|
||||
}
|
||||
}
|
||||
|
||||
fun create(source: KotlinType): CirType = source.unwrap().run {
|
||||
when (this) {
|
||||
is SimpleType -> create(this)
|
||||
is FlexibleType -> CirFlexibleType(create(lowerBound), create(upperBound))
|
||||
}
|
||||
}
|
||||
|
||||
fun create(source: SimpleType): CirSimpleType {
|
||||
if (source is AbbreviatedType) {
|
||||
val abbreviation = source.abbreviation
|
||||
when (val classifierDescriptor = abbreviation.declarationDescriptor) {
|
||||
is TypeAliasDescriptor -> {
|
||||
return createTypeAliasType(
|
||||
typeAliasId = classifierDescriptor.classifierId,
|
||||
underlyingType = create(extractExpandedType(source)) as CirClassOrTypeAliasType,
|
||||
arguments = createArguments(abbreviation.arguments),
|
||||
isMarkedNullable = abbreviation.isMarkedNullable
|
||||
)
|
||||
}
|
||||
else -> error("Unexpected classifier descriptor type for abbreviation type: ${classifierDescriptor::class.java}, $classifierDescriptor, ${source.abbreviation}")
|
||||
}
|
||||
}
|
||||
|
||||
return when (val classifierDescriptor = source.declarationDescriptor) {
|
||||
is ClassDescriptor -> createClassTypeWithAllOuterTypes(
|
||||
classDescriptor = classifierDescriptor,
|
||||
arguments = createArguments(source.arguments),
|
||||
isMarkedNullable = source.isMarkedNullable
|
||||
)
|
||||
is TypeAliasDescriptor -> {
|
||||
val abbreviatedType = TypeAliasExpander.NON_REPORTING.expand(
|
||||
TypeAliasExpansion.create(null, classifierDescriptor, source.arguments),
|
||||
Annotations.EMPTY
|
||||
) as AbbreviatedType
|
||||
|
||||
val expandedType = extractExpandedType(abbreviatedType)
|
||||
|
||||
val cirExpandedType = create(expandedType) as CirClassOrTypeAliasType
|
||||
val cirExpandedTypeWithProperNullability = makeNullableIfNecessary(cirExpandedType, source.isMarkedNullable)
|
||||
|
||||
createTypeAliasType(
|
||||
typeAliasId = classifierDescriptor.classifierId,
|
||||
underlyingType = cirExpandedTypeWithProperNullability,
|
||||
arguments = createArguments(source.arguments),
|
||||
isMarkedNullable = source.isMarkedNullable
|
||||
)
|
||||
}
|
||||
is TypeParameterDescriptor -> createTypeParameterType(classifierDescriptor.typeParameterIndex, source.isMarkedNullable)
|
||||
else -> error("Unexpected classifier descriptor type: ${classifierDescriptor::class.java}, $classifierDescriptor, $source")
|
||||
}
|
||||
}
|
||||
|
||||
fun createClassType(
|
||||
classId: CirEntityId,
|
||||
outerType: CirClassType?,
|
||||
@@ -226,7 +174,7 @@ object CirTypeFactory {
|
||||
fun unabbreviate(type: CirClassOrTypeAliasType): CirClassType = when (type) {
|
||||
is CirClassType -> {
|
||||
var hasAbbreviationsInArguments = false
|
||||
val unabreviatedArguments = type.arguments.compactMap { argument ->
|
||||
val unabbreviatedArguments = type.arguments.compactMap { argument ->
|
||||
val argumentType =
|
||||
(argument as? CirTypeProjectionImpl)?.type as? CirClassOrTypeAliasType ?: return@compactMap argument
|
||||
val unabbreviatedArgumentType = unabbreviate(argumentType)
|
||||
@@ -252,55 +200,13 @@ object CirTypeFactory {
|
||||
classId = type.classifierId,
|
||||
outerType = unabbreviatedOuterType,
|
||||
visibility = type.visibility,
|
||||
arguments = unabreviatedArguments,
|
||||
arguments = unabbreviatedArguments,
|
||||
isMarkedNullable = type.isMarkedNullable
|
||||
)
|
||||
}
|
||||
is CirTypeAliasType -> unabbreviate(computeExpandedType(type))
|
||||
}
|
||||
|
||||
private fun createClassTypeWithAllOuterTypes(
|
||||
classDescriptor: ClassDescriptor,
|
||||
arguments: List<CirTypeProjection>,
|
||||
isMarkedNullable: Boolean
|
||||
): CirClassType {
|
||||
val outerType: CirClassType?
|
||||
val remainingArguments: List<CirTypeProjection>
|
||||
|
||||
if (classDescriptor.isInner) {
|
||||
val declaredTypeParametersCount = classDescriptor.declaredTypeParameters.size
|
||||
outerType = createClassTypeWithAllOuterTypes(
|
||||
classDescriptor = classDescriptor.containingDeclaration as ClassDescriptor,
|
||||
arguments = arguments.subList(declaredTypeParametersCount, arguments.size),
|
||||
isMarkedNullable = false // don't pass nullable flag to outer types
|
||||
)
|
||||
remainingArguments = arguments.subList(0, declaredTypeParametersCount)
|
||||
} else {
|
||||
outerType = null
|
||||
remainingArguments = arguments
|
||||
}
|
||||
|
||||
return createClassType(
|
||||
classId = classDescriptor.classifierId,
|
||||
outerType = outerType,
|
||||
visibility = classDescriptor.visibility,
|
||||
arguments = remainingArguments,
|
||||
isMarkedNullable = isMarkedNullable
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
private inline fun createArguments(arguments: List<TypeProjection>): List<CirTypeProjection> =
|
||||
arguments.compactMap { projection ->
|
||||
if (projection.isStarProjection)
|
||||
CirStarTypeProjection
|
||||
else
|
||||
CirTypeProjectionImpl(
|
||||
projectionKind = projection.projectionKind,
|
||||
type = create(projection.type)
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
private inline fun createArguments(arguments: List<KmTypeProjection>, typeResolver: CirTypeResolver): List<CirTypeProjection> {
|
||||
return arguments.compactMap { argument ->
|
||||
@@ -313,24 +219,6 @@ object CirTypeFactory {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private inline val TypeParameterDescriptor.typeParameterIndex: Int
|
||||
get() {
|
||||
var index = index
|
||||
var parent = containingDeclaration
|
||||
|
||||
if (parent is CallableMemberDescriptor) {
|
||||
parent = parent.containingDeclaration as? ClassifierDescriptorWithTypeParameters ?: return index
|
||||
index += parent.declaredTypeParameters.size
|
||||
}
|
||||
|
||||
while (parent is ClassifierDescriptorWithTypeParameters) {
|
||||
parent = parent.containingDeclaration as? ClassifierDescriptorWithTypeParameters ?: break
|
||||
index += parent.declaredTypeParameters.size
|
||||
}
|
||||
|
||||
return index
|
||||
}
|
||||
}
|
||||
|
||||
typealias TypeParameterId = Int
|
||||
|
||||
-9
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.descriptors.commonizer.cir.factory
|
||||
import kotlinx.metadata.Flag
|
||||
import kotlinx.metadata.KmTypeParameter
|
||||
import kotlinx.metadata.klib.annotations
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirAnnotation
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||
@@ -21,14 +20,6 @@ import org.jetbrains.kotlin.descriptors.commonizer.utils.filteredUpperBounds
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
object CirTypeParameterFactory {
|
||||
fun create(source: TypeParameterDescriptor): CirTypeParameter = create(
|
||||
annotations = source.annotations.compactMap(CirAnnotationFactory::create),
|
||||
name = CirName.create(source.name),
|
||||
isReified = source.isReified,
|
||||
variance = source.variance,
|
||||
upperBounds = source.filteredUpperBounds.compactMap(CirTypeFactory::create)
|
||||
)
|
||||
|
||||
fun create(source: KmTypeParameter, typeResolver: CirTypeResolver): CirTypeParameter = create(
|
||||
annotations = CirAnnotationFactory.createAnnotations(ALWAYS_HAS_ANNOTATIONS, typeResolver, source::annotations),
|
||||
name = CirName.create(source.name),
|
||||
|
||||
@@ -8,8 +8,6 @@ package org.jetbrains.kotlin.descriptors.commonizer.utils
|
||||
import kotlinx.metadata.ClassName
|
||||
import kotlinx.metadata.KmAnnotation
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirPackageName
|
||||
@@ -73,12 +71,5 @@ internal val CirPackageName.isUnderKotlinNativeSyntheticPackages: Boolean
|
||||
internal val CirEntityId.isObjCInteropCallableAnnotation: Boolean
|
||||
get() = packageName == CINTEROP_PACKAGE && relativeNameSegments.singleOrNull() in OBJC_INTEROP_CALLABLE_ANNOTATIONS
|
||||
|
||||
internal val AnnotationDescriptor.isObjCInteropCallableAnnotation: Boolean
|
||||
get() {
|
||||
val classifier = type.declarationDescriptor
|
||||
return CirName.create(classifier.name) in OBJC_INTEROP_CALLABLE_ANNOTATIONS
|
||||
&& (classifier.containingDeclaration as? PackageFragmentDescriptor)?.fqName?.let(CirPackageName::create) == CINTEROP_PACKAGE
|
||||
}
|
||||
|
||||
internal val KmAnnotation.isObjCInteropCallableAnnotation: Boolean
|
||||
get() = className in OBJC_INTEROP_CALLABLE_ANNOTATION_FULL_NAMES
|
||||
|
||||
@@ -7,50 +7,12 @@ package org.jetbrains.kotlin.descriptors.commonizer.utils
|
||||
|
||||
import gnu.trove.TIntHashSet
|
||||
import kotlinx.metadata.*
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirPackageName
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeSignature
|
||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.TypeParameterResolver
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.typeUtil.isNullableAny
|
||||
|
||||
internal inline val KotlinType.declarationDescriptor: ClassifierDescriptor
|
||||
get() = (constructor.declarationDescriptor ?: error("No declaration descriptor found for $constructor"))
|
||||
|
||||
// eliminate unnecessary repeated abbreviations
|
||||
internal fun extractExpandedType(abbreviated: AbbreviatedType): SimpleType {
|
||||
var expanded = abbreviated.expandedType
|
||||
while (expanded is AbbreviatedType) {
|
||||
if (expanded.abbreviation.declarationDescriptor !== abbreviated.abbreviation.declarationDescriptor)
|
||||
break
|
||||
else
|
||||
expanded = expanded.expandedType
|
||||
}
|
||||
return expanded
|
||||
}
|
||||
|
||||
internal val ClassifierDescriptorWithTypeParameters.classifierId: CirEntityId
|
||||
get() = when (val owner = containingDeclaration) {
|
||||
is PackageFragmentDescriptor -> CirEntityId.create(
|
||||
packageName = CirPackageName.create(owner.fqName),
|
||||
relativeName = CirName.create(name)
|
||||
)
|
||||
is ClassDescriptor -> owner.classifierId.createNestedEntityId(CirName.create(name))
|
||||
else -> error("Unexpected containing declaration type for $this: ${owner::class}, $owner")
|
||||
}
|
||||
|
||||
internal inline val TypeParameterDescriptor.filteredUpperBounds: List<KotlinType>
|
||||
get() = upperBounds.takeUnless { it.singleOrNull()?.isNullableAny() == true } ?: emptyList()
|
||||
|
||||
internal inline val KmTypeParameter.filteredUpperBounds: List<KmType>
|
||||
get() = upperBounds.takeUnless { it.singleOrNull()?.isNullableAny == true } ?: emptyList()
|
||||
|
||||
internal inline val ClassDescriptor.filteredSupertypes: Collection<KotlinType>
|
||||
get() = typeConstructor.supertypes.takeUnless { it.size == 1 && KotlinBuiltIns.isAny(it.first()) } ?: emptyList()
|
||||
|
||||
internal inline val KmClass.filteredSupertypes: List<KmType>
|
||||
get() = supertypes.takeUnless { it.singleOrNull()?.isAny == true } ?: emptyList()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user