forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request scala#1227 from dotty-staging/implement-1221
Allow to specify per-callsite @tailrec annotation.
- Loading branch information
Showing
4 changed files
with
50 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import annotation.tailrec | ||
|
||
object I1221{ | ||
final def foo(a: Int): Int = { | ||
if ((foo(a - 1): @tailrec) > 0) // error: not in tail position | ||
foo(a - 1): @tailrec | ||
else | ||
foo(a - 2): @tailrec | ||
} | ||
} |
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 annotation.tailrec | ||
|
||
class Test { | ||
def foo(a: Int): Int = { // error: method is not final | ||
if ((foo(a - 1): @tailrec) > 0) | ||
foo(a - 1): @tailrec | ||
else | ||
foo(a - 2): @tailrec | ||
} | ||
} |
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 annotation.tailrec | ||
|
||
object i1221{ | ||
final def foo(a: Int): Int = { | ||
if (foo(a - 1) > 0) | ||
foo(a - 1): @tailrec | ||
else | ||
foo(a - 2): @tailrec | ||
} | ||
} |