Use type parameters' source information for kotlinx.serialization diagnostics

To be more consistent with K1, certain diagnostics should be reported
not on the whole properties' types, but on type arguments inside them.

Note that there is still a difference with K2 because K2 reports on a type argument
including its annotations, while K1 used KtTypeReference.typeElement.

IMO, K2 conveys the same or better meaning here, so I am willing to leave this
difference instead of providing PositioningStrategy.

#KT-53861 Fixed
This commit is contained in:
Leonid Startsev
2023-11-22 18:03:24 +01:00
committed by Space Team
parent a22a254c1e
commit f7d87f6d70
6 changed files with 61 additions and 38 deletions
@@ -1,6 +1,6 @@
// FIR_DISABLE_LAZY_RESOLVE_CHECKS
// WITH_STDLIB
// FIR_DIFFERENCE: KT-53861
// FIR_IDENTICAL
// FILE: test.kt
import kotlinx.serialization.*
@@ -12,6 +12,9 @@ class Basic(val foo: <!SERIALIZER_NOT_FOUND("NonSerializable")!>NonSerializable<
@Serializable
class Inside(val foo: List<<!SERIALIZER_NOT_FOUND("NonSerializable")!>NonSerializable<!>>)
@Serializable
class Inside2(val foo: List<List<<!SERIALIZER_NOT_FOUND("NonSerializable")!>NonSerializable<!>>>)
@Serializable
class WithImplicitType {
<!SERIALIZER_NOT_FOUND("NonSerializable")!>val foo = NonSerializable()<!>