[descriptors] Move DeclarationDescriptor#findPackage helper to core

There is nothing serialization-specific about this function
This commit is contained in:
Sergej Jaskiewicz
2023-08-23 12:52:15 +02:00
committed by teamcity
parent dff2d2ed60
commit 5cb252fe49
7 changed files with 10 additions and 14 deletions
@@ -24,10 +24,8 @@ internal val DeclarationDescriptor.isExpectMember: Boolean
internal val DeclarationDescriptor.isSerializableExpectClass: Boolean
get() = this is ClassDescriptor && OptionalAnnotationUtil.shouldGenerateExpectClass(this)
tailrec fun DeclarationDescriptor.findPackage(): PackageFragmentDescriptor {
return if (this is PackageFragmentDescriptor) this
else this.containingDeclaration!!.findPackage()
}
@Deprecated("Moved to the ':core:descriptors' module", level = DeprecationLevel.HIDDEN)
fun DeclarationDescriptor.findPackage(): PackageFragmentDescriptor = findPackage()
private fun sourceByIndex(descriptor: CallableMemberDescriptor, index: Int): SourceFile {
val fragment = descriptor.findPackage() as KlibMetadataDeserializedPackageFragment