Files
kotlin-fork/compiler/testData/diagnostics/klibSerializationTests/signatureClash.kt
T
Sergej Jaskiewicz d80a67652f [klib] Fix NIE when showing signature clash diagnostics on properties
The issue was that when rendering declarations in
the `CONFLICTING_KLIB_SIGNATURES_DATA` diagnostics, we sort them using
`MemberComparator`. That comparator falls back to comparing
declarations' renders if all previous checks were unsuccessful
(and in case of almost identical properties they are). The renderer that
the comparator uses also renders the properties' backing field
annotations, for which it calls `PropertyDescriptor#getBackingField`.
That method wasn't implemented in IR-based descriptors.

This is fixed by returning an instance of the new
`IrBasedBackingFieldDescriptor` class from that method.

^KT-65551 Fixed
2024-02-09 16:45:34 +00:00

48 lines
1.5 KiB
Kotlin
Vendored

// 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
<!CONFLICTING_KLIB_SIGNATURES_ERROR!>@Deprecated("", level = DeprecationLevel.HIDDEN)
fun foo(): Long = 0L<!>
<!CONFLICTING_KLIB_SIGNATURES_ERROR, CONFLICTING_KLIB_SIGNATURES_ERROR, CONFLICTING_KLIB_SIGNATURES_ERROR!>var myVal: Long = 0L<!>
// FILE: main.kt
package com.example.klib.serialization.diagnostics
<!CONFLICTING_KLIB_SIGNATURES_ERROR!>@Deprecated("", level = DeprecationLevel.HIDDEN)
fun foo(): String = ""<!>
<!CONFLICTING_KLIB_SIGNATURES_ERROR!>fun foo(): Int = 0<!>
<!CONFLICTING_KLIB_SIGNATURES_ERROR, CONFLICTING_KLIB_SIGNATURES_ERROR, CONFLICTING_KLIB_SIGNATURES_ERROR!>@Deprecated("", level = DeprecationLevel.HIDDEN)
var myVal: Int = 0<!>
<!CONFLICTING_KLIB_SIGNATURES_ERROR!>@Deprecated("", level = DeprecationLevel.HIDDEN)
val myVal: String
<!CONFLICTING_KLIB_SIGNATURES_ERROR!>get() = ""<!><!>
@Deprecated("This function moved to the 'lib' module", level = DeprecationLevel.HIDDEN)
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<!>