-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle @serializable classes that implement interfaces by delegation
by filtering out delegated properties that end up in irClass.properties() list Fixes Kotlin/kotlinx.serialization#2157 (cherry picked from commit dc0cd61)
- Loading branch information
1 parent
d5e97c6
commit 2d1e8db
Showing
4 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
plugins/kotlinx-serialization/testData/boxIr/delegatedInterface.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// TARGET_BACKEND: JVM_IR | ||
|
||
// WITH_STDLIB | ||
|
||
import kotlinx.serialization.* | ||
import kotlinx.serialization.descriptors.* | ||
import kotlinx.serialization.encoding.* | ||
import kotlinx.serialization.json.* | ||
|
||
@Serializable() | ||
class Dto( | ||
val data: Map<Int, Int> | ||
) : Map<Int, Int> by data | ||
|
||
fun box(): String { | ||
val dto = Dto(mapOf(1 to 2)) | ||
val s = Json.encodeToString(dto) | ||
if (s != """{"data":{"1":2}}""") return s | ||
val d = Json.decodeFromString<Dto>(s) | ||
if (d.size != 1) return "Delegation to Map failed" | ||
if (d.data != dto.data) return "Equals failed ${d.data}" | ||
return "OK" | ||
} |
6 changes: 6 additions & 0 deletions
6
...en/org/jetbrains/kotlinx/serialization/runners/SerializationFirBlackBoxTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...ests-gen/org/jetbrains/kotlinx/serialization/runners/SerializationIrBoxTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.