Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SerialInfo annotations on enum classes are not saved in 1.7.20+ #2121

Closed
sandwwraith opened this issue Dec 12, 2022 · 0 comments
Closed

SerialInfo annotations on enum classes are not saved in 1.7.20+ #2121

sandwwraith opened this issue Dec 12, 2022 · 0 comments

Comments

@sandwwraith
Copy link
Member

sandwwraith commented Dec 12, 2022

Describe the bug

SerialInfo annotations on enum classes (not members!) were saved up to Kotlin 1.7.10, but starting from 1.7.20 they're lost.

To Reproduce

@SerialInfo
@Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY)
annotation class A(val i: Int)

@A(1)
@Serializable
enum class Baz {
    @A(2) X, @A(3) Y
}

@Test
fun enumTest() {
    val d = Baz.serializer().descriptor
    println(d.annotations)
    println(d.getElementAnnotations(0))
    println(d.getElementAnnotations(1))
}

Expected behavior

On 1.7.10 test printed:

[kotlinx.serialization.A$Impl@65b5b5ed]
[kotlinx.serialization.A$Impl@795eddda]
[kotlinx.serialization.A$Impl@c6bf8d9]

On 1.7.20 test prints:

[]
[kotlinx.serialization.A$Impl@6bc85459]
[kotlinx.serialization.A$Impl@64a67067]

Reason:

In 1.7.20, factory function

internal fun <T : Enum<T>> createMarkedEnumSerializer(
is used instead of generated $serializer for enums. It doesn't have slots for class-level annotations.

shanshin added a commit to JetBrains/kotlin that referenced this issue Dec 13, 2022
shanshin added a commit to JetBrains/kotlin that referenced this issue Dec 14, 2022
shanshin added a commit that referenced this issue Dec 14, 2022
…he class (#2125)

Resolves #2121

Co-authored-by: Leonid Startsev <sandwwraith@users.noreply.github.com>
shanshin added a commit to JetBrains/kotlin that referenced this issue Dec 15, 2022
shanshin added a commit to JetBrains/kotlin that referenced this issue Dec 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants