-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add @binaryAPI
and @binaryAPIAccessor
#16992
Closed
nicolasstucki
wants to merge
11
commits into
scala:main
from
dotty-staging:add-binary-api-annotation
Closed
Add @binaryAPI
and @binaryAPIAccessor
#16992
nicolasstucki
wants to merge
11
commits into
scala:main
from
dotty-staging:add-binary-api-annotation
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nicolasstucki
force-pushed
the
add-binary-api-annotation
branch
19 times, most recently
from
February 27, 2023 07:44
0a55e7f
to
d1460af
Compare
nicolasstucki
force-pushed
the
add-binary-api-annotation
branch
2 times, most recently
from
February 27, 2023 09:25
9fd92fd
to
dd786ce
Compare
nicolasstucki
force-pushed
the
add-binary-api-annotation
branch
3 times, most recently
from
February 28, 2023 07:52
908df98
to
7025414
Compare
nicolasstucki
force-pushed
the
add-binary-api-annotation
branch
2 times, most recently
from
February 28, 2023 08:54
241874f
to
b19652a
Compare
nicolasstucki
force-pushed
the
add-binary-api-annotation
branch
from
February 28, 2023 10:22
b19652a
to
41bf75b
Compare
I split the old version of |
nicolasstucki
added
the
needs-minor-release
This PR cannot be merged until the next minor release
label
Feb 28, 2023
nicolasstucki
force-pushed
the
add-binary-api-annotation
branch
from
March 23, 2023 08:16
41bf75b
to
d4472ae
Compare
The `@binaryAPI` annotation will make any package private or protected term definition public in the generated bytecode. Definitions that override an `@binaryAPI` will also become public. We cannot annotate `private[this]` definitions because we might have different definitions with the same name and signature in a subclass. These would clash if made public. Instead of using private/private[this], the user can write `private[C]` where `C` is the enclosing class. This is useful in combination with inline definitions. If an inline definition refers to a `private`/`protected` definition marked as `@binaryAPI` it does not need to use an accessor. We still generate the accessors for binary compatibility but do not use them.
In this case the annotation will generate a public accessor (and setter). This accessor has a consistent name that avoids clashes (`<className>$inline$<definitionName>`). It will have the same name as a private accessor that would have been generate in a non final class by the old inline accessor generation.
Users should add the old accessor explicitly to keep binary compatibility. This accessor should be `@binaryAPI private[C]` where `C` is the enclosing class.
* `@binaryAPI` makes the API public. Cannot be used on `private[this]`. * `@binaryAPIAccessor` generates the private accessor.
nicolasstucki
force-pushed
the
add-binary-api-annotation
branch
from
May 9, 2023 07:50
e921fdd
to
35610f1
Compare
nicolasstucki
force-pushed
the
add-binary-api-annotation
branch
from
May 9, 2023 08:01
35610f1
to
6ae7082
Compare
In objects, we can use `inline$<definitionName>` for the name of this accessor. This is the same name as would have been generated automatically.
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds
@binaryAPI
and@binaryAPIAccessor
.@binaryAPI
A binary API is a definition that is annotated with
@binaryAPI
or overrides a definition annotated with@binaryAPI
. This annotation can be placed ondef
,val
,lazy val
,var
,object
, andgiven
definitions. A binary API will be publicly available in the bytecode. It cannot be used onprivate
/private[this]
definitions.@binaryAPIAccessor
A binary API with accessor is a definition that is annotated with
@binaryAPIAccessor
.This annotation can be placed on
def
,val
,lazy val
,var
,object
, andgiven
definitions. The annotated definition will get a public accessor named<fullClassName>$$inline$<definitionName>
.Interaction with
inline
This is useful in combination with inline definitions. If an inline definition refers to a private/protected definition marked as
@binaryAPI
it does not need to use an accessor. We still generate the accessors for binary compatibility but do not use them.References
SIP: scala/improvement-proposals#58
Part of the fix for #13215
Part of the fix for #15413
Part of the fix for #16983
Alternative to #16985