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

Introduce @SealedSerializationApi to codebase and stabilize part of SerialDescriptor's API #2827

Merged
merged 4 commits into from
Oct 9, 2024

Conversation

sandwwraith
Copy link
Member

Same as #2764 but without @AdvancedEncodingApi. It seems that https://youtrack.jetbrains.com/issue/KTIJ-30831 is fixed only in K2 IDE and only in Kotlin 2.1, so introducing @AdvancedEncodingApi now may lead to poor UX for 3rd party format authors

@sandwwraith
Copy link
Member Author

Build with Kotlin master failed because of Kotlin/dokka#3851

* Yet it is not type-checked statically, thus making it possible to declare a non-consistent implementations of descriptor and serializer.
* In such cases, the behaviour of an underlying format is unspecified and may lead to both runtime errors and encoding of
* Yet it is not type-checked statically, thus making it possible to declare a non-consistent implementation of descriptor and serializer.
* In such cases, the behavior of an underlying format is unspecified and may lead to both runtime errors and encoding of
Copy link
Contributor

Choose a reason for hiding this comment

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

We use both options, is this change definitely necessary?

Copy link
Member Author

@sandwwraith sandwwraith Oct 8, 2024

Choose a reason for hiding this comment

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

IIRC general doc guideline dictates the usage of American English, so all spelling should be converted to this one eventually

This API has been around for a long time and has proven itself useful. The main reason @ExperimentalSerializationApi was on SerialDescriptor's properties is that we wanted to discourage people from subclassing it. With the introduction of @SubclassOptInRequired (#2366), we can do this without the need of marking everything with experimental.

Serial kinds fall into the same category with only exception in PolymorphicKind. There are plenty requests for functionality like creating a custom sealed-like descriptor (#2697, #2721, #1865) which may require additional kinds in the future.
and allow creating primitive descriptors via it as well.

This constructor function is a way to create a descriptor for your
custom serializer if it simply delegates to an existing one.
Since it fits its purpose and is unlikely to change in the future, we can promote it to stable API
alongside other descriptor builders.

Fixes #2547
to be used with @SubclassOptInRequired.

This annotation allows for even more fine-grained API marking. We now can designate APIs
as public for use, but closed for implementation — the case for SerialDescriptor, which is a non-sealed interface for technical reasons.
@sandwwraith sandwwraith force-pushed the subclass-optin-required-2 branch from aed3864 to 4e7eed3 Compare October 9, 2024 13:25
@sandwwraith sandwwraith merged commit 99be485 into dev Oct 9, 2024
4 checks passed
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.

4 participants