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

Serializable meta-annotation #1678

Closed
wants to merge 2 commits into from

Conversation

rsinukov
Copy link
Contributor

@pdvrieze
Copy link
Contributor

Overall a good idea. There is one challenge, if you use a custom serializer it doesn't make sense to provide any other values for the annotation (custom serializers don't have access to generated descriptors - it is broken in many ways, but if they are generic even more). As an alternative, why not use:

interface SerializerFactory<A: Annotation> {
   fun getSerializer<T>(type:KClass, annotation: A): KSerializer<T>
}

This provides the factory the opportunity to return the serializer needed for that specific type (and meta annotation).

@MetaSerializable
@Target(AnnotationTarget.CLASS)
annotation class MySerializable(
@MetaSerializable.Serializer val with: KClass<out KSerializer<*>> = KSerializer::class,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obsolete test?

@sandwwraith
Copy link
Member

Since JetBrains/kotlin#4583 goes to 1.7.0, I'll merge this when the corresponding release would be prepared.

@sandwwraith
Copy link
Member

Transferred commit to #1979

@sandwwraith sandwwraith closed this Jul 4, 2022
@rsinukov rsinukov deleted the rsinukov/meta-serializable branch July 4, 2022 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants