-
Notifications
You must be signed in to change notification settings - Fork 614
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
@file:UseContextualSerialization doesn't work with actual typealias on Kotlin 2.0.0 #2704
Comments
Quick question: does it work with 2.0 when |
Apparently it doesn't work with regular typealias as well. This is all you need to have a compile error with 2.0.0: @file:UseContextualSerialization(MyDate::class)
package com.example
import kotlinx.serialization.Serializable
import kotlinx.serialization.UseContextualSerialization
typealias MyDate = java.time.LocalDate
@Serializable
data class MyClass(val d: MyDate?)
fun main() {
} The same file compiles fine with 1.9.24. |
Thanks, I'll take a look on it. |
By the way, your original reproducer (with |
…annotation because they are expanded for properties types Fixes Kotlin/kotlinx.serialization#2704
You are right. I've simplified my example too much without checking. In my project, the expect class and typealias are defined in a multiplatform library. But the rest of the code is the same and the |
…annotation because they are expanded for properties types Fixes Kotlin/kotlinx.serialization#2704
…annotation because they are expanded for properties types Fixes Kotlin/kotlinx.serialization#2704
When using a
@file:UseContextualSerialization
annotation with an expected type declared in common target and defined asactual typealias
on other targets, the compiler reports an error about missing serializer.To, Reproduce
common code:
common code, different file:
jvm code:
The compiler fails with an error message:
Expected behavior
No error. The same code works fine with Kotlin 1.9.24.
Using
@Contextual
annotation directly on a property works as well.Environment
The text was updated successfully, but these errors were encountered: