[KLIB tool] "dump-metadata-signatures": exclude fake overrides

There are few reasons why fake overrides should not be printed:

1. Fake overrides are not serialized in metadata. So, if one will run
   "dump-metadata" they won't see there any fake overrides. Neither
   their signatures. It would be inconsistent if
   "dump-metadata-signatures" command would show them.

2. In order to properly build fake overrides the KLIB tool needs
   the dependency library with the super class or interface, which
   is not available unless this is stdlib or one of the built-in
   Kotlin/Native platform libraries. KLIB tool does not support any
   reasonable means for passing dependencies through CLI arguments.
   If such possibility is added in the future, it would be the
   right time to support printing fake overrides (probably under
   a separate CLI option).

^KT-62340
This commit is contained in:
Dmitriy Dolovov
2024-02-19 23:00:08 +01:00
committed by Space Team
parent f4f609bea7
commit 795ee9f26d
@@ -36,11 +36,11 @@ internal class SignaturePrinter(
}
override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, data: Unit) {
extractSignatureFromDeclaration(descriptor)
extractSignatureFromCallableMember(descriptor)
}
override fun visitPropertyDescriptor(descriptor: PropertyDescriptor, data: Unit) {
extractSignatureFromDeclaration(descriptor) {
extractSignatureFromCallableMember(descriptor) {
descriptor.getter?.let(::extractSignatureFromDeclaration)
descriptor.setter?.let(::extractSignatureFromDeclaration)
}
@@ -54,6 +54,13 @@ internal class SignaturePrinter(
extractSignatureFromDeclaration(descriptor)
}
private inline fun extractSignatureFromCallableMember(descriptor: CallableMemberDescriptor, continuation: () -> Unit = {}) {
// Skip fake overrides.
if (descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) return
extractSignatureFromDeclaration(descriptor, continuation)
}
private inline fun extractSignatureFromDeclaration(descriptor: DeclarationDescriptorWithVisibility, continuation: () -> Unit = {}) {
val isPrivate = when (descriptor.visibility) {
DescriptorVisibilities.PUBLIC,
@@ -70,3 +77,4 @@ internal class SignaturePrinter(
}
}
}