-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preventing compilation of a @tailrec method when it does not rewrite,…
… but an inner method does (#20143) Adding warnings if there is an annotated def at the top level that is referenced from an inner def Fixes #20105
- Loading branch information
Showing
8 changed files
with
83 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- [E199] Syntax Warning: tests/neg/i20105.scala:6:9 ------------------------------------------------------------------- | ||
6 | foo() | ||
| ^^^^^ | ||
| The tail recursive def foo contains a recursive call inside the non-inlined inner def bar | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E097] Syntax Error: tests/neg/i20105.scala:3:4 --------------------------------------------------------------------- | ||
3 |def foo(): Unit = // error | ||
| ^ | ||
| TailRec optimisation not applicable, method foo contains no recursive calls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import scala.annotation.tailrec | ||
@tailrec | ||
def foo(): Unit = // error | ||
def bar(): Unit = | ||
if (???) | ||
foo() | ||
else | ||
bar() | ||
bar() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- [E199] Syntax Warning: tests/warn/i20105.scala:6:9 ------------------------------------------------------------------ | ||
6 | foo() // warn | ||
| ^^^^^ | ||
| The tail recursive def foo contains a recursive call inside the non-inlined inner def bar | ||
| | ||
| longer explanation available when compiling with `-explain` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import scala.annotation.tailrec | ||
@tailrec | ||
def foo(): Unit = | ||
def bar(): Unit = | ||
if (???) | ||
foo() // warn | ||
else | ||
bar() | ||
bar() | ||
foo() |