-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Warn if interpolator uses toString #20578
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
Conversation
68521a8
to
e788f89
Compare
The Scala 2 version of this will ship very soon (in 2.13.15). |
@som-snytt may I ask you why did you close this pr? I would love to use this flag 🙏 |
a2ebaa0
to
941615f
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.
Looks good overall! I added some minor comments.
compiler/src/dotty/tools/dotc/transform/localopt/FormatChecker.scala
Outdated
Show resolved
Hide resolved
compiler/src/dotty/tools/dotc/transform/localopt/FormatChecker.scala
Outdated
Show resolved
Hide resolved
case _ => true | ||
|
||
def lintToString(arg: Type): Unit = | ||
if ctx.settings.Whas.toStringInterpolated && kind == StringXn && !(arg.widen =:= defn.StringType) && !arg.isPrimitiveValueType | ||
then warningAt(CC)("interpolation uses 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.
This would probably be better, when done as a separate PR, but it might be useful to add message ids for all the error/warning messages in this file.
941615f
to
6fc84a6
Compare
I took the suggestions, and added an error ID and kind for the messages, which look better that way. (Such a small change to make such a big difference.) (Probably There are too many specific messages for more granularity. Also minor refactoring or formatting for readability. Some of the long one-liners look like it's trying to save paper for a print-out. |
295bcc9
to
d96843b
Compare
d96843b
to
ba4204e
Compare
Ports scala/scala#10776
"I always forget how to use Scala 3."