-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Locally is inline #24851
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
base: main
Are you sure you want to change the base?
Locally is inline #24851
Conversation
|
Unfortunately, that is not backward binary compatible. Fortunately, it shouldn't matter, because the JIT can eliminate it. |
|
Ah yes. If I'm unable to add it to Edit: I noticed one weird trick -- |
afc4d27 to
858d5e5
Compare
library/src/scala/Predef.scala
Outdated
| * @group utilities | ||
| */ | ||
| @inline def locally[T](@deprecatedName("x") x: T): T = x | ||
| inline override def locally[T](@deprecatedName("x") x: T): T = x |
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.
We had a chat at some point at EPFL about potentially having an annotation to require the method to remain in the binary. I would hold on doing such acrobatics until the final decision about this.
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 looked at publicInBinary (which would be reasonable) or special-casing locally in Inlines, but this works today and is an insignificant delta.
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.
cherry-picked @elidable(0) from another PR.
858d5e5 to
8c0382a
Compare
|
I have already contributed "ignore line numbers in stack traces of tests" in another PR that is waiting patiently on the queue. |
The two usages of
locallyin the code base are actually just to parenthesizeif-elsein a boolean expression.Because
locallyis notinline, that requires boxing the boolean, which is unused.Inlining
locallymakes using it guilt-free. The signature is not changed here. To preserve bincompat, it overrides a non-inline method.This commit fixes a doc typo and makes a boolean expression more readable with leading infix operators. Normally leading infix is requested during code review, but this was after a round of edits. Here, it makes a difference to help distinguish the
ifconditional from thethenresult expression.Also fix the tests that fail on current JVM. It is locally annoying and a time waste at 666ff49.