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

Get rid of @Suppress("INVISIBLE_REFERENCE") for usage of internal declarations #2444

Merged
merged 7 commits into from
Sep 21, 2023

Conversation

sandwwraith
Copy link
Member

  • Make shared declarations public (with exception for copy-pasted ESCAPE_STRINGS)
  • Introduce additional internal opt-in annotation to hide declarations even more
  • Rename JsonWriter and SerialReader to something more internal-ish
  • Refactor internal extensions on Json into top-level functions to remove them from completion (because even optable-in declarations are shown in completion for all users)

TODO: cherry-pick to mainline dev
Refactor internal extensions on Json into top-level functions to remove them from completion (because even optable-in declarations are shown in completion for all users)
Copy link
Contributor

@pdvrieze pdvrieze left a comment

Choose a reason for hiding this comment

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

There are some uses of double-optin with the superInternal annotations. Seems a bit superfluous.

*/
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
internal annotation class SuperInternalSerializationApi
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's rename it to something a bit more specific? FriendModuleApi would be a nice fit.

I'd also suggest not to write in the KDoc how to opt-in into that :)

By the way, how does IDEA behave when trying to use declaration marked with such an annotation?

Copy link
Member Author

Choose a reason for hiding this comment

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

IDEA shows standard opt-in error and even suggests quickfix action. If one uses quickfix, an @OptIn is inserted with a red annotation reference saying, 'It is internal in kotlinx.serialization.internal`

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please report it to KTIJ?

IDEA shouldn't suggest a quickfix here; ideally, it shouldn't suggest an autocompletion either if it's known in advance one cannot opt-in into that

Copy link
Member Author

Choose a reason for hiding this comment

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

IDEA shouldn't suggest a quickfix here

I'm not sure about that. It looks to me that IDEA behavior is correct, and we're just abusing the internal visibility of annotation. There's no feature in the opt-in design that 'opt-in shouldn't be suggested if annotation is invisible'

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree we might be stretching optin capabilities, yet IDEA clearly suggests the red code here.
Problem is going to get worse if we'll start leveraging this pattern more

Copy link
Member Author

Choose a reason for hiding this comment

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

@qwwdfsad qwwdfsad self-requested a review September 19, 2023 13:46
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