[klib] Don't rely on Lazy IR for signature clash checking

We only want to report signature clashes for declarations that come
from the module currently being serialized. In GlobalDeclarationTable,
declarations from other modules could also be stored.
Checking whether a declaration is a Lazy IR declaration to
determine if it comes from an external module works okay, but it is
a hack which relies on an implementation detail of IR, which may or
may not work in the future.

Use a more robust logic here, since IrFileSerializer is always aware
which declarations are declared in the current module and which are
just referenced from it.
This commit is contained in:
Sergej Jaskiewicz
2024-01-30 15:50:12 +01:00
committed by Space Team
parent 55a87f301b
commit 06684f207a
5 changed files with 40 additions and 32 deletions
@@ -12,3 +12,11 @@
fun foo(): kotlin.Long defined in com.example.klib.serialization.diagnostics
fun foo(): kotlin.String defined in com.example.klib.serialization.diagnostics
fun foo(): kotlin.Int defined in com.example.klib.serialization.diagnostics
/main.kt:35:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/bar|bar(){}[0]):
fun bar(): kotlin.Long defined in com.example.klib.serialization.diagnostics
fun bar(): kotlin.Long defined in com.example.klib.serialization.diagnostics
/main.kt:38:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/bar|bar(){}[0]):
fun bar(): kotlin.Long defined in com.example.klib.serialization.diagnostics
fun bar(): kotlin.Long defined in com.example.klib.serialization.diagnostics
@@ -27,4 +27,12 @@ fun movedToLib() {}
fun main() {
foo()
movedToLib()
// Test that the diagnostic is reported for declarations that are referenced before they are declared
bar()
}
<!CONFLICTING_KLIB_SIGNATURES_ERROR!>@Deprecated("", level = DeprecationLevel.HIDDEN)
fun bar(): Long = 0L<!>
<!CONFLICTING_KLIB_SIGNATURES_ERROR!>fun bar(): Long = 1L<!>