-
Notifications
You must be signed in to change notification settings - Fork 21
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
Implement the Any2StringAdd rewrite #10
Conversation
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.
Looks good already! Interesting that it works for bool + s
but not byte + s
...
|
||
private def addToString(term: Term) = term match { | ||
case _: Term.Name | _: Term.Select | _: Term.Block => Patch.addRight(term, ".toString") | ||
case _ => Patch.addLeft(term, "(") + Patch.addRight(term, ").toString") |
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.
my only concern here is that it unnecessarily boxes primitives.
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.
Ah, that must be why the deprecation message for these is to use string interpolation.
Should we do "" + x
for these? (And "" + (...)
for non-Name/Select/Block.) . Or should we try to rewrite it to use string interpolation?
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 don't know. IIRC, string interpolation is special-cased by the compiler in 2.13, so it's probably at least as efficient as other options, if not more so?
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.
Yeah it's the right choice. But for mechanical rewrites you could get some weird rewrites, so maybe this is best?
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.
that must be why the deprecation message for these is to use string interpolation.
IIRC, string interpolation is special-cased by the compiler in 2.13
Yes. see scala/scala#7201 scala/bug#11025
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.
nice 👍
Part of scala/scala-dev#327