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

Enable Serializable annotation to be given to Type Parameter as well #2892

Open
TBSten opened this issue Dec 25, 2024 · 0 comments
Open

Enable Serializable annotation to be given to Type Parameter as well #2892

TBSten opened this issue Dec 25, 2024 · 0 comments
Labels

Comments

@TBSten
Copy link

TBSten commented Dec 25, 2024

What is your use-case and why do you need this feature?

Some functions, such as Navigation Compose's TypeSafe DSL, require the Type Parameter they accept to be Serializable. Currently this can only be a run-time error.

Describe the solution you'd like

These should be checked at compile-time to improve the development experience.

// ⭐️ Should allow @Serializable to be given to Type Parameter T
fun <@Serializable T> someFun() { TODO() }

@Serializable
class MySerializable

class MyNotSerializable

fun test() {
    someFun<String>() // 🟢 OK
    someFun<String>() // 🟢 OK
    someFun<MySerializable>() // 🔴 NG(Compile error): someFun.T must be @Serializable
}
@TBSten TBSten added the feature label Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant