[klib] Fix exception for clashing signatures from different modules

If we encounter a declaration in the current module whose signature
is the same as that of a declaration in another module which we happen
to also reference from the current module, don't report any errors,
just like we don't do it in Kotlin/JVM. This leaves the user in the KLIB
hell situation, but this is intentional, because otherwise a legitimate
change like moving a declaration to another module and marking
the original one as `@Deprecated("", level = DeprecationLevel.HIDDEN)`
would lead to a error, and we don't want that.

Also, don't try to show the diagnostics on a declaration that doesn't
have an IrFile.

^KT-65063 Fixed
This commit is contained in:
Sergej Jaskiewicz
2024-01-18 15:58:50 +01:00
committed by Space Team
parent a5c8ecae0b
commit 6900e20096
8 changed files with 62 additions and 14 deletions
@@ -1,14 +1,14 @@
/foo.kt:7:1: error: Platform declaration clash: The following declarations have the same KLIB signature (com.example.klib.serialization.diagnostics/foo|foo(){}[0]):
/foo.kt:13:1: error: Platform declaration clash: The following declarations have the same KLIB signature (com.example.klib.serialization.diagnostics/foo|foo(){}[0]):
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:13:1: error: Platform declaration clash: The following declarations have the same KLIB signature (com.example.klib.serialization.diagnostics/foo|foo(){}[0]):
/main.kt:19:1: error: Platform declaration clash: The following declarations have the same KLIB signature (com.example.klib.serialization.diagnostics/foo|foo(){}[0]):
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:16:1: error: Platform declaration clash: The following declarations have the same KLIB signature (com.example.klib.serialization.diagnostics/foo|foo(){}[0]):
/main.kt:22:1: error: Platform declaration clash: The following declarations have the same KLIB signature (com.example.klib.serialization.diagnostics/foo|foo(){}[0]):
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
@@ -1,6 +1,12 @@
// FIR_IDENTICAL
// RENDER_ALL_DIAGNOSTICS_FULL_TEXT
// MODULE: lib
package com.example.klib.serialization.diagnostics
fun movedToLib() {}
// MODULE: main(lib)
// FILE: foo.kt
package com.example.klib.serialization.diagnostics
@@ -15,6 +21,10 @@ fun foo(): String = ""<!>
<!CONFLICTING_KLIB_SIGNATURES_ERROR!>fun foo(): Int = 0<!>
@Deprecated("This function moved to the 'lib' module", level = DeprecationLevel.HIDDEN)
fun movedToLib() {}
fun main() {
foo()
movedToLib()
}