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

@publicInBinary override spec change #19296

Merged

Conversation

nicolasstucki
Copy link
Contributor

Followup of #18402 (see #18402 (comment)).

This was split from the main PR due to the blocker described in #18402 (comment). During the Dotty meeting, we decided to merge #18402 without the second commit (Require @publicInBinary on overrides). If we manage to fix this issue before 3.4.0-RC1 we will include it there, otherwise it will be part of 3.4.0-RC2.

@@ -544,6 +544,12 @@ object Checking {
else if !sym.owner.isClass && !(sym.is(Param) && sym.owner.isConstructor) then fail(em"@publicInBinary cannot be used on local definitions")
else if sym.is(ParamAccessor) && sym.is(Private) then fail(em"@publicInBinary cannot be non `val` constructor parameters")
else if sym.is(Private) && !sym.privateWithin.exists && !sym.isConstructor then fail(em"@publicInBinary cannot be used on private definitions\n\nConsider using `private[${sym.owner.name}]` or `protected` instead")
else
sym.allOverriddenSymbols.find(sym => sym.hasAnnotation(defn.PublicInBinaryAnnot)) match
Copy link
Member

Choose a reason for hiding this comment

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

As mentioned by @smarter somewhere else, there's a good chance that this code would behave much better in RefChecks. One of the main purposes of RefChecks is to check properties across the inheritance chain of methods, so it would make sense there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made the change. I will test the community build with the CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It worked

@nicolasstucki nicolasstucki force-pushed the binaryAPI-override-spec-change branch from 5e80305 to dcf42cf Compare December 19, 2023 10:37
@nicolasstucki nicolasstucki marked this pull request as ready for review December 19, 2023 13:15
@nicolasstucki nicolasstucki requested a review from sjrd December 19, 2023 13:38
@nicolasstucki nicolasstucki removed their assignment Dec 19, 2023
Comment on lines 583 to 584
else if !member.hasAnnotation(defn.PublicInBinaryAnnot) && other.hasAnnotation(defn.PublicInBinaryAnnot) then
overrideError("also needs to be declared with @publicInBinary")
Copy link
Member

Choose a reason for hiding this comment

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

This must come before the overrideDeprecation test, otherwise a deprecation warning can shadow an actual error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved and updated docs.

@nicolasstucki nicolasstucki force-pushed the binaryAPI-override-spec-change branch from dcf42cf to 7205496 Compare December 19, 2023 14:15
@nicolasstucki nicolasstucki requested a review from sjrd December 19, 2023 14:17
@nicolasstucki nicolasstucki merged commit eae8831 into scala:main Dec 19, 2023
17 checks passed
@nicolasstucki nicolasstucki deleted the binaryAPI-override-spec-change branch December 19, 2023 16:43
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.

2 participants