-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add new style error message for @tailrec #3312
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
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.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
dc1c089
to
bc6ac51
Compare
@@ -1786,4 +1787,15 @@ object messages { | |||
|If you want to create an ${"enum"} case, make sure the corresponding ${"enum class"} exists | |||
|and has the ${"enum"} keyword.""" | |||
} | |||
|
|||
|
|||
case class TailrecNotApplicableNeitherPrivateNorFinal(owner: Symbol)(implicit ctx: Context) |
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 would simply call it TailrecNotApplicable
and TailrecNotApplicableID
@@ -1786,4 +1787,15 @@ object messages { | |||
|If you want to create an ${"enum"} case, make sure the corresponding ${"enum class"} exists | |||
|and has the ${"enum"} keyword.""" | |||
} | |||
|
|||
|
|||
case class TailrecNotApplicableNeitherPrivateNorFinal(owner: Symbol)(implicit ctx: Context) |
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.
method
is a better name than owner
| @scala.annotation.tailrec | ||
| def foo: Unit = foo | ||
| | ||
|} |
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 file is already big enough. Let's remove unnecessary blank lines:
"""class Foo {
| @scala.annotation.tailrec
| def foo: Unit = foo
|}
""".stripMargin
case class TailrecNotApplicableNeitherPrivateNorFinal(owner: Symbol)(implicit ctx: Context) | ||
extends Message(TailrecNotApplicableNeitherPrivateNorFinalID) { | ||
val kind = "Syntax" | ||
val msg = hl"TailRec optimisation not applicable, ${owner} is neither `private` nor `final` so can be overridden" |
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.
val msg = hl"TailRec optimisation not applicable, $owner is neither ${"private"} nor ${"final"}."
val explanation = | ||
hl""" | ||
|The `@tailrec` annotation can only be used on methods that are either `private` or `final`. | ||
""" |
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.
val explanation =
hl"A method annotated ${"@tailrec"} must be declared ${"private"} or ${"final"} so it can't be overridden."
8f434b9
to
fef6455
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.
LGTM! Thanks 🎉
see #1589