[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
This commit is contained in:
Sergej Jaskiewicz
2024-02-08 19:01:50 +01:00
committed by Space Team
parent 9688c3e761
commit d80a67652f
5 changed files with 196 additions and 72 deletions
@@ -3,20 +3,58 @@
fun foo(): kotlin.String defined in com.example.klib.serialization.diagnostics
fun foo(): kotlin.Int defined in com.example.klib.serialization.diagnostics
/main.kt:19:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/foo|foo(){}[0]):
/foo.kt:16:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal|{}myVal[0]):
val myVal: kotlin.String defined in com.example.klib.serialization.diagnostics
var myVal: kotlin.Int defined in com.example.klib.serialization.diagnostics
var myVal: kotlin.Long defined in com.example.klib.serialization.diagnostics
/foo.kt:16:1: error: Platform declaration clash: The following declarations have the same IR signature ([ com.example.klib.serialization.diagnostics/myVal|{}myVal[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:myVal type:kotlin.Long visibility:private [static]] ]):
var myVal: kotlin.Int defined in com.example.klib.serialization.diagnostics
var myVal: kotlin.Long defined in com.example.klib.serialization.diagnostics
/foo.kt:16:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal.<get-myVal>|<get-myVal>(){}[0]):
fun `<get-myVal>`(): kotlin.Int defined in com.example.klib.serialization.diagnostics
fun `<get-myVal>`(): kotlin.Long defined in com.example.klib.serialization.diagnostics
fun `<get-myVal>`(): kotlin.String defined in com.example.klib.serialization.diagnostics
/main.kt:21:1: error: Platform declaration clash: The following declarations have the same IR 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:22:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/foo|foo(){}[0]):
/main.kt:24:1: error: Platform declaration clash: The following declarations have the same IR 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:35:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/bar|bar(){}[0]):
/main.kt:26:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal|{}myVal[0]):
val myVal: kotlin.String defined in com.example.klib.serialization.diagnostics
var myVal: kotlin.Int defined in com.example.klib.serialization.diagnostics
var myVal: kotlin.Long defined in com.example.klib.serialization.diagnostics
/main.kt:26:1: error: Platform declaration clash: The following declarations have the same IR signature ([ com.example.klib.serialization.diagnostics/myVal|{}myVal[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:myVal type:kotlin.Long visibility:private [static]] ]):
var myVal: kotlin.Int defined in com.example.klib.serialization.diagnostics
var myVal: kotlin.Long defined in com.example.klib.serialization.diagnostics
/main.kt:26:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal.<get-myVal>|<get-myVal>(){}[0]):
fun `<get-myVal>`(): kotlin.Int defined in com.example.klib.serialization.diagnostics
fun `<get-myVal>`(): kotlin.Long defined in com.example.klib.serialization.diagnostics
fun `<get-myVal>`(): kotlin.String defined in com.example.klib.serialization.diagnostics
/main.kt:29:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal|{}myVal[0]):
val myVal: kotlin.String defined in com.example.klib.serialization.diagnostics
var myVal: kotlin.Int defined in com.example.klib.serialization.diagnostics
var myVal: kotlin.Long defined in com.example.klib.serialization.diagnostics
/main.kt:31:5: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal.<get-myVal>|<get-myVal>(){}[0]):
fun `<get-myVal>`(): kotlin.Int defined in com.example.klib.serialization.diagnostics
fun `<get-myVal>`(): kotlin.Long defined in com.example.klib.serialization.diagnostics
fun `<get-myVal>`(): kotlin.String defined in com.example.klib.serialization.diagnostics
/main.kt:44: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]):
/main.kt:47: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
@@ -13,6 +13,8 @@ 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
@@ -21,6 +23,13 @@ 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() {}