-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
HiddenFromObjC and ShouldRefineInSwift annotations #4818
HiddenFromObjC and ShouldRefineInSwift annotations #4818
Conversation
22e7381
to
628898d
Compare
Hi. Thank you for the PR! We will take a look later, hopefully next week. |
628898d
to
0ddd39f
Compare
kotlin-native/runtime/src/main/kotlin/kotlin/native/Annotations.kt
Outdated
Show resolved
Hide resolved
kotlin-native/runtime/src/main/kotlin/kotlin/native/Annotations.kt
Outdated
Show resolved
Hide resolved
...iler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportMapper.kt
Outdated
Show resolved
Hide resolved
...iler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportMapper.kt
Outdated
Show resolved
Hide resolved
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.
Once the design/names are finalised we'll still need to update the KDocs of the annotations.
...e/frontend/src/org/jetbrains/kotlin/resolve/konan/diagnostics/NativeObjCRefinementChecker.kt
Outdated
Show resolved
Hide resolved
...iler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportMapper.kt
Outdated
Show resolved
Hide resolved
...ve/frontend/src/org/jetbrains/kotlin/resolve/konan/diagnostics/DefaultErrorMessagesNative.kt
Outdated
Show resolved
Hide resolved
...e/frontend/src/org/jetbrains/kotlin/resolve/konan/diagnostics/NativeObjCRefinementChecker.kt
Outdated
Show resolved
Hide resolved
...ve/frontend/src/org/jetbrains/kotlin/resolve/konan/diagnostics/DefaultErrorMessagesNative.kt
Outdated
Show resolved
Hide resolved
557d903
to
f086075
Compare
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.
At this point, the implementation looks fine. Great job!
Status: We are waiting for a review of the stdlib part from the Kotlin Libraries team.
I'm also going to run the CI one more time, to check the latest changes.
kotlin-native/runtime/src/main/kotlin/kotlin/native/Annotations.kt
Outdated
Show resolved
Hide resolved
kotlin-native/runtime/src/main/kotlin/kotlin/native/Annotations.kt
Outdated
Show resolved
Hide resolved
...e/frontend/src/org/jetbrains/kotlin/resolve/konan/diagnostics/NativeObjCRefinementChecker.kt
Outdated
Show resolved
Hide resolved
049d270
to
f994fcf
Compare
...ackend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportHeaderGenerator.kt
Outdated
Show resolved
Hide resolved
kotlin-native/runtime/src/main/kotlin/kotlin/native/Annotations.kt
Outdated
Show resolved
Hide resolved
6bc887d
to
34748bf
Compare
34748bf
to
9913de5
Compare
3240dbe
to
37a46bd
Compare
@rickclephas could you please run |
@SvyatoslavScherbina done 👍🏻 |
...s/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt
Outdated
Show resolved
Hide resolved
...ests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendNativeDiagnosticsTestGenerated.java
Show resolved
Hide resolved
...tive/src/org/jetbrains/kotlin/fir/analysis/native/checkers/FirNativeObjCRefinementChecker.kt
Outdated
Show resolved
Hide resolved
...tive/src/org/jetbrains/kotlin/fir/analysis/native/checkers/FirNativeObjCRefinementChecker.kt
Outdated
Show resolved
Hide resolved
...tive/src/org/jetbrains/kotlin/fir/analysis/native/checkers/FirNativeObjCRefinementChecker.kt
Outdated
Show resolved
Hide resolved
...tive/src/org/jetbrains/kotlin/fir/analysis/native/checkers/FirNativeObjCRefinementChecker.kt
Outdated
Show resolved
Hide resolved
...tive/src/org/jetbrains/kotlin/fir/analysis/native/checkers/FirNativeObjCRefinementChecker.kt
Outdated
Show resolved
Hide resolved
...org/jetbrains/kotlin/fir/analysis/native/checkers/FirNativeObjCRefinementOverridesChecker.kt
Outdated
Show resolved
Hide resolved
@rickclephas Thank you! From the side of FIR part everything is ok.
|
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.
The code looks good to me (as I said, I have zero experience in FIR, so I didn't check FIR checkers thoroughly, and rely on the @demiurg906 approval here). Still waiting for the CI. Once we get the green builds and the commit history is cleaned up, we will merge the PR.
c42ac90
to
f38bf05
Compare
Cool! Updated the name and squashed the commits into three new ones. |
@demiurg906 would you like a PR for the FIR checkers (with similar improvements) for |
@rickclephas Yes, it would be nice |
f38bf05
to
5940d53
Compare
Thank you! |
Relates to KT-42297.
The Kotlin ObjC/Swift is pretty great, but at the moment there are also some gaps (especially with the Swift interop) like suspend functions and enum classes.
With some boilerplate code the interop for such code can be improved, which can even be automated with a compiler plugin/annotation processor.
However one limitation of such boilerplate code is that it adds unnecessary declarations to your public API.
With the
HiddenFromObjC
andShouldRefineInSwift
annotations we can hide these unnecessary declarations from the public API.We also have the meta-annotations
HidesFromObjC
andRefinesInSwift
such that annotation processors can generate ObjC/Swift friendly APIs while automatically hiding the original declaration.HiddenFromObjC
Functions and properties annotated with the
HiddenFromObjC
annotation won't be exported to ObjC.This allows you to create a more ObjC friendly version in your Kotlin code.
ShouldRefineInSwift
The
ShouldRefineInSwift
annotation adds theswift_private
attribute to the declaration.This results in the declarations being prefixed with
__
, which make them "invisible" from Swift.These declarations can still be used in your Swift code to create your Swift friendly API, but won't be shown in e.g. the Xcode autocomplete.