Add tests for JVM backend diagnostics with K2 light tree

In the vast majority of tests, diagnostics are reported at a slightly
different location in LT vs PSI. This is because in the light tree mode,
backend errors are reported basically on the start of the IR element,
which is for example the keyword "class" for a class and not its name as
in K1 or in K2+PSI. Similarly, the end of the diagnostic is at the
ending offset of the IR element.

Normally it would be a bit user-unfriendly to highlight the whole class
as red, starting from the keyword "class" and ending with the closing
brace "}". But remember that these are backend diagnostics in the K2+LT
mode, which is only possible in the compiler scenario, not in the IDE.
And in this case, the ending offset doesn't matter at all because it's
not presented to the user, and minor change in the starting offset is
not a problem as well.

There are some tests which legitimately fail in the LT mode because the
corresponding diagnostics haven't been supported. They will be dealt
with in subsequent commits:

  testPropertyInlineCycle
  testInlineCycle
  MultifileClasses.testJvmSynthetic
  testSuspendInlineCycle
  testIndirectInlineCycle

 #KT-59586
This commit is contained in:
Alexander Udalov
2023-06-22 17:19:36 +02:00
parent 69c698134b
commit 5f2ff06296
140 changed files with 1511 additions and 137 deletions
@@ -0,0 +1,15 @@
// COMPARE_WITH_LIGHT_TREE
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface Foo<X> {
fun foo(x: X)
}
open class FooImpl : Foo<String> {
override fun foo(x: String) {
}
}
open class FooImpl2 : FooImpl() {
<!ACCIDENTAL_OVERRIDE{LT}!><!ACCIDENTAL_OVERRIDE{PSI}!>fun foo(x: Any)<!> {
}<!>
}
@@ -1,4 +1,4 @@
// FIR_IDENTICAL
// COMPARE_WITH_LIGHT_TREE
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface Foo<X> {
fun foo(x: X)
@@ -1,8 +1,10 @@
// COMPARE_WITH_LIGHT_TREE
open class B {
fun getX() = 1
}
class C : B() {
<!ACCIDENTAL_OVERRIDE!>val x: Int<!>
get() = 1
<!ACCIDENTAL_OVERRIDE{LT}!><!ACCIDENTAL_OVERRIDE{PSI}!>val x: Int<!>
get() = 1<!>
}
@@ -1,3 +1,5 @@
// COMPARE_WITH_LIGHT_TREE
open class B {
fun getX() = 1
}
@@ -5,4 +7,4 @@ open class B {
class C : B() {
val x: Int
<!ACCIDENTAL_OVERRIDE!>get()<!> = 1
}
}
@@ -0,0 +1,9 @@
// COMPARE_WITH_LIGHT_TREE
open class B {
fun getX() = 1
}
class C : B() {
<!ACCIDENTAL_OVERRIDE{LT}!><!ACCIDENTAL_OVERRIDE{PSI}!>val x: Int<!> = 1<!>
}
@@ -1,8 +1,9 @@
// FIR_IDENTICAL
// COMPARE_WITH_LIGHT_TREE
open class B {
fun getX() = 1
}
class C : B() {
<!ACCIDENTAL_OVERRIDE!>val x: Int<!> = 1
}
}
@@ -0,0 +1,10 @@
// COMPARE_WITH_LIGHT_TREE
open class B {
val x: Int
get() = 1
}
class C : B() {
<!ACCIDENTAL_OVERRIDE{LT}!><!ACCIDENTAL_OVERRIDE{PSI}!>fun getX()<!> = 1<!>
}
@@ -1,4 +1,5 @@
// FIR_IDENTICAL
// COMPARE_WITH_LIGHT_TREE
open class B {
val x: Int
get() = 1
@@ -6,4 +7,4 @@ open class B {
class C : B() {
<!ACCIDENTAL_OVERRIDE!>fun getX()<!> = 1
}
}
@@ -0,0 +1,10 @@
// COMPARE_WITH_LIGHT_TREE
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class Base {
open fun `foo$default`(d: Derived, i: Int, mask: Int, mh: Any) {}
}
class Derived : Base() {
<!ACCIDENTAL_OVERRIDE{LT}!><!ACCIDENTAL_OVERRIDE{PSI}!>fun foo(i: Int = 0)<!> {}<!>
}
@@ -1,4 +1,4 @@
// FIR_IDENTICAL
// COMPARE_WITH_LIGHT_TREE
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class Base {
@@ -0,0 +1,10 @@
// COMPARE_WITH_LIGHT_TREE
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class B {
fun foo(l: List<String>) {}
}
class C : B() {
<!ACCIDENTAL_OVERRIDE{LT}!><!ACCIDENTAL_OVERRIDE{PSI}!>fun foo(l: List<Int>)<!> {}<!>
}
@@ -1,4 +1,4 @@
// FIR_IDENTICAL
// COMPARE_WITH_LIGHT_TREE
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class B {
@@ -7,4 +7,4 @@ open class B {
class C : B() {
<!ACCIDENTAL_OVERRIDE!>fun foo(l: List<Int>)<!> {}
}
}
@@ -0,0 +1,9 @@
// COMPARE_WITH_LIGHT_TREE
interface B {
fun getX() = 1
}
class C : B {
<!ACCIDENTAL_OVERRIDE{LT}!><!ACCIDENTAL_OVERRIDE{PSI}!><!NOTHING_TO_OVERRIDE!>override<!> val x<!> = 1<!>
}
@@ -1,8 +1,9 @@
// FIR_IDENTICAL
// COMPARE_WITH_LIGHT_TREE
interface B {
fun getX() = 1
}
class C : B {
<!ACCIDENTAL_OVERRIDE!><!NOTHING_TO_OVERRIDE!>override<!> val x<!> = 1
}
}
@@ -1,8 +1,10 @@
// COMPARE_WITH_LIGHT_TREE
interface T {
fun getX() = 1
}
class C : T {
<!ACCIDENTAL_OVERRIDE!>val x: Int<!>
get() = 1
<!ACCIDENTAL_OVERRIDE{LT}!><!ACCIDENTAL_OVERRIDE{PSI}!>val x: Int<!>
get() = 1<!>
}
@@ -1,3 +1,5 @@
// COMPARE_WITH_LIGHT_TREE
interface T {
fun getX() = 1
}
@@ -5,4 +7,4 @@ interface T {
class C : T {
val x: Int
<!ACCIDENTAL_OVERRIDE!>get()<!> = 1
}
}
@@ -1,8 +1,10 @@
// COMPARE_WITH_LIGHT_TREE
interface T {
fun getX(): Int
}
abstract class C : T {
<!ACCIDENTAL_OVERRIDE!>val x: Int<!>
get() = 1
<!ACCIDENTAL_OVERRIDE{LT}!><!ACCIDENTAL_OVERRIDE{PSI}!>val x: Int<!>
get() = 1<!>
}
@@ -1,3 +1,5 @@
// COMPARE_WITH_LIGHT_TREE
interface T {
fun getX(): Int
}
@@ -5,4 +7,4 @@ interface T {
abstract class C : T {
val x: Int
<!ACCIDENTAL_OVERRIDE!>get()<!> = 1
}
}
@@ -0,0 +1,10 @@
// COMPARE_WITH_LIGHT_TREE
interface T {
val x: Int
get() = 1
}
class C : T {
<!ACCIDENTAL_OVERRIDE{LT}!><!ACCIDENTAL_OVERRIDE{PSI}!>fun getX()<!> = 1<!>
}
@@ -1,4 +1,4 @@
// FIR_IDENTICAL
// COMPARE_WITH_LIGHT_TREE
interface T {
val x: Int
@@ -0,0 +1,9 @@
// COMPARE_WITH_LIGHT_TREE
interface T {
val x: Int
}
abstract class C : T {
<!ACCIDENTAL_OVERRIDE{LT}!><!ACCIDENTAL_OVERRIDE{PSI}!>fun getX()<!> = 1<!>
}
@@ -1,8 +1,9 @@
// FIR_IDENTICAL
// COMPARE_WITH_LIGHT_TREE
interface T {
val x: Int
}
abstract class C : T {
<!ACCIDENTAL_OVERRIDE!>fun getX()<!> = 1
}
}