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

@rsinukov rsinukov force-pushed the rsinukov/meta-serializable branch from e2cda39 to a0936e3 Compare October 11, 2021 15:49
@rsinukov rsinukov force-pushed the rsinukov/meta-serializable branch from a0936e3 to 0edaff7 Compare October 11, 2021 15:51
@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).

@rsinukov rsinukov force-pushed the rsinukov/meta-serializable branch from bd67d7f to d2b3268 Compare December 21, 2021 12:26
@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?

@rsinukov rsinukov force-pushed the rsinukov/meta-serializable branch from d2b3268 to 29806d0 Compare February 8, 2022 16:27
@rsinukov rsinukov requested a review from sandwwraith February 8, 2022 16:27
@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