FIR Checker: check tailrec

Difference from FE1.0
* KT-4285: calls to virtual method with default argument should be
  reported as not tailrec. FE1.0 is missing such cases.
* KT-48600: calls inside lambda should be reported as not tailrec. FE1.0
  also misses such cases.
This commit is contained in:
Tianyu Geng
2021-09-02 11:00:45 -07:00
committed by TeamCityServer
parent 5df316a129
commit 8525b4932b
55 changed files with 876 additions and 216 deletions
@@ -1,15 +1,15 @@
//!LANGUAGE: -ProhibitTailrecOnVirtualMember
open class A {
tailrec open fun foo(x: Int) {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec open fun foo(x: Int)<!> {
foo(x)
}
internal tailrec open fun bar(y: Int) {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>internal tailrec open fun bar(y: Int)<!> {
bar(y)
}
protected tailrec open fun baz(y: Int) {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>protected tailrec open fun baz(y: Int)<!> {
baz(y)
}
@@ -38,15 +38,15 @@ open class B : A() {
open class C : A() {
tailrec override fun foo(x: Int) {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec override fun foo(x: Int)<!> {
foo(x)
}
tailrec override fun bar(y: Int) {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec override fun bar(y: Int)<!> {
bar(y)
}
tailrec override fun baz(y: Int) {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec override fun baz(y: Int)<!> {
baz(y)
}
}
@@ -66,15 +66,15 @@ object D : A() {
}
sealed class E : A() {
tailrec override fun foo(x: Int) {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec override fun foo(x: Int)<!> {
foo(x)
}
tailrec override fun bar(y: Int) {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec override fun bar(y: Int)<!> {
bar(y)
}
tailrec override fun baz(y: Int) {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec override fun baz(y: Int)<!> {
baz(y)
}
@@ -109,15 +109,15 @@ enum class F {
}
};
tailrec open fun foo(x: Int) {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec open fun foo(x: Int)<!> {
foo(x)
}
internal tailrec open fun bar(y: Int) {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>internal tailrec open fun bar(y: Int)<!> {
bar(y)
}
protected tailrec open fun baz(y: Int) {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>protected tailrec open fun baz(y: Int)<!> {
baz(y)
}
@@ -134,15 +134,15 @@ enum class G {
G1;
tailrec open fun foo(x: Int) {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec open fun foo(x: Int)<!> {
foo(x)
}
internal tailrec open fun bar(y: Int) {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>internal tailrec open fun bar(y: Int)<!> {
bar(y)
}
protected tailrec open fun baz(y: Int) {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>protected tailrec open fun baz(y: Int)<!> {
baz(y)
}