-
Notifications
You must be signed in to change notification settings - Fork 628
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
Conversation
sandwwraith
commented
Sep 15, 2023
- 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)
There was a problem hiding this 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.
formats/json/commonMain/src/kotlinx/serialization/json/internal/JsonStreams.kt
Outdated
Show resolved
Hide resolved
formats/json/commonMain/src/kotlinx/serialization/json/internal/JsonStreams.kt
Outdated
Show resolved
Hide resolved
*/ | ||
@RequiresOptIn(level = RequiresOptIn.Level.ERROR) | ||
internal annotation class SuperInternalSerializationApi |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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`
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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'
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.