FIR checker: report tailrec problems on the keyword

FE1.0 reports it on the declaration signature. This is not ideal so we
move it to the `tailrec` keyword in FIR.
This commit is contained in:
Tianyu Geng
2021-09-23 20:34:27 -07:00
committed by teamcityserver
parent 922ae607f6
commit 5252effb10
26 changed files with 86 additions and 74 deletions
+10 -10
View File
@@ -2,17 +2,17 @@
// WITH_STDLIB
// !DIAGNOSTICS: -UNREACHABLE_CODE
<!NO_TAIL_CALLS_FOUND!>tailrec fun foo1()<!> {
<!NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo1() {
<!NON_TAIL_RECURSIVE_CALL!>foo1<!>()
1
}
<!NO_TAIL_CALLS_FOUND!>tailrec fun foo2()<!> {
<!NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo2() {
<!NON_TAIL_RECURSIVE_CALL!>foo2<!>()
val i = 1
}
<!NO_TAIL_CALLS_FOUND!>tailrec fun foo3()<!> {
<!NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo3() {
<!NON_TAIL_RECURSIVE_CALL!>foo3<!>()
foo1()
}
@@ -27,7 +27,7 @@ tailrec fun foo5() {
foo4()
}
<!NO_TAIL_CALLS_FOUND!>tailrec fun foo6(b: Boolean)<!> {
<!NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo6(b: Boolean) {
while (b) {
<!NON_TAIL_RECURSIVE_CALL!>foo6<!>(!b)
}
@@ -40,21 +40,21 @@ tailrec fun foo7_return() {
}
}
<!NO_TAIL_CALLS_FOUND!>tailrec fun foo7_break()<!> {
<!NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo7_break() {
while (true) {
<!NON_TAIL_RECURSIVE_CALL!>foo7_break<!>()
break
}
}
<!NO_TAIL_CALLS_FOUND!>tailrec fun foo7_continue()<!> {
<!NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo7_continue() {
while (true) {
<!NON_TAIL_RECURSIVE_CALL!>foo7_continue<!>()
continue
}
}
<!NO_TAIL_CALLS_FOUND!>tailrec fun foo8()<!> {
<!NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo8() {
while (true) {
<!NON_TAIL_RECURSIVE_CALL!>foo8<!>()
throw Exception()
@@ -62,19 +62,19 @@ tailrec fun foo7_return() {
foo8()
}
<!NO_TAIL_CALLS_FOUND!>tailrec fun foo9()<!> {
<!NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo9() {
<!NON_TAIL_RECURSIVE_CALL!>foo9<!>()
fun bar() {}
}
<!NO_TAIL_CALLS_FOUND!>tailrec fun foo10()<!> {
<!NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo10() {
<!NON_TAIL_RECURSIVE_CALL!>foo10<!>()
class Bar {
val i = 1
}
}
<!NO_TAIL_CALLS_FOUND!>tailrec fun foo11(): String<!> {
<!NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo11(): String {
return "hello ${<!NON_TAIL_RECURSIVE_CALL!>foo11<!>()}"
}