[LL FIR] KT-50732 Add support for LL FIR-specific tests (.ll.kt)

- `.ll.kt` test data can be added in cases where LL FIR resolution
  legally diverges from K2 compiler results.
- Each `.ll.kt` test is prefixed with an `LL_FIR_DIVERGENCE` directive
  which must explain why the test may diverge from K2 compiler results.
  - `LLFirDivergenceCommentChecker` ensures that each `.ll.kt` file
    contains an `LL_FIR_DIVERGENCE` directive.
- `LLFirIdenticalChecker` results in an assertion error if the `.ll.kt`
  test and its base test are completely identical, including in their
  meta info (but ignoring `LL_FIR_DIVERGENCE`).
  - The checker additionally ensures that the base source file and the
    `.ll.kt` source file have identical Kotlin source code (ignoring
    meta info and `LL_FIR_DIVERGENCE`). This ensures that both tests
    test the exact same thing.
- `.ll.kt` files are ignored by select test generators, in addition to
  `.fir.kt` files.
This commit is contained in:
Marco Pennekamp
2022-12-02 19:01:54 +01:00
committed by teamcity
parent b0db0f59b4
commit 88ac5727cc
52 changed files with 3706 additions and 3010 deletions
@@ -1,4 +1,3 @@
// FIR_IDE_IGNORE
// FILE: I.kt
open class I : K() {
@@ -1,4 +1,3 @@
// FIR_IDE_IGNORE
// FILE: I.kt
open class I : <!CYCLIC_INHERITANCE_HIERARCHY!>K<!>() {
@@ -0,0 +1,21 @@
// LL_FIR_DIVERGENCE
// The compiler doesn't guarantee exhaustiveness in reporting of inheritance cycles, so the compiler and LL FIR results are equally valid.
// LL_FIR_DIVERGENCE
// FILE: I.kt
open class I : <!CYCLIC_INHERITANCE_HIERARCHY!>K<!>() {
fun foo() {}
}
// FILE: J.java
class J extends I {
void bar() {}
}
// FILE: K.kt
open class K : <!CYCLIC_INHERITANCE_HIERARCHY!>J<!>() {
fun baz() {}
}
@@ -1,5 +1,4 @@
// FIR_IDENTICAL
// FIR_IDE_IGNORE
// FILE: f1.kt
package test
@@ -0,0 +1,17 @@
// LL_FIR_DIVERGENCE
// The compiler reports `PACKAGE_OR_CLASSIFIER_REDECLARATION` on both `A`s, but the LL FIR APIs output is also workable. The underlying
// issue is already reported: KTIJ-23371.
// LL_FIR_DIVERGENCE
// FIR_IDENTICAL
// FILE: f1.kt
package test
class A
class F1
// FILE: f2.kt
package test
class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>A<!>
class F2
@@ -1,4 +1,3 @@
// FIR_IDE_IGNORE
// FILE: file1.kt
private class C {
companion object
@@ -1,4 +1,3 @@
// FIR_IDE_IGNORE
// FILE: file1.kt
private class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>C<!> {
companion object
@@ -0,0 +1,27 @@
// LL_FIR_DIVERGENCE
// Which file `INVISIBLE_REFERENCE` is reported in is unspecified behavior. LL FIR does worse than the compiler in that it doesn't report
// `PACKAGE_OR_CLASSIFIER_REDECLARATION` on either instance of `C` and `TA`, but this is a separate issue: KTIJ-23371.
// LL_FIR_DIVERGENCE
// FILE: file1.kt
private class C {
companion object
}
private typealias TA = C
private val test1: C = C()
private val test1co: C.Companion = C
private val test2: TA = TA()
private val test2co = TA
// FILE: file2.kt
private val test1: <!INVISIBLE_REFERENCE!>C<!> = <!INVISIBLE_REFERENCE!>C<!>()
private val test1co: <!INVISIBLE_REFERENCE!>C.Companion<!> = <!INVISIBLE_REFERENCE!>C<!>
private val test2: <!INVISIBLE_REFERENCE!>TA<!> = <!INVISIBLE_REFERENCE!>TA<!>()
private val test2co = <!INVISIBLE_REFERENCE!>TA<!>
private class C
private typealias TA = Int