Skip to content

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

Merged
merged 3 commits into from
Oct 24, 2017

Conversation

esarbe
Copy link
Contributor

@esarbe esarbe commented Oct 12, 2017

see #1589

Copy link
Member

@dottybot dottybot left a 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! ☀️

@esarbe esarbe force-pushed the messages-tailrec2 branch from dc1c089 to bc6ac51 Compare October 12, 2017 08:01
@@ -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)
Copy link
Contributor

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)
Copy link
Contributor

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
|
|}
Copy link
Contributor

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"
Copy link
Contributor

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`.
"""
Copy link
Contributor

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."

@esarbe esarbe force-pushed the messages-tailrec2 branch from 8f434b9 to fef6455 Compare October 24, 2017 16:47
Copy link
Contributor

@allanrenucci allanrenucci left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks 🎉

@allanrenucci allanrenucci merged commit 431f0fc into scala:master Oct 24, 2017
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.

3 participants