JVM IR: restore ability to suppress codegen-reported diagnostics

In the old backend, BindingContextSuppressCache is used (which is now
created explicitly in GenerationState), which looks up `@Suppress`
annotations on elements right before reporting the diagnostic. In JVM
IR, we clear the binding context after psi2ir, so this approach doesn't
work. This change provides another implementation of KotlinSuppressCache
which eagerly precomputes all suppressions on all annotated elements in
all source files at the point of creation of GenerationState (when the
binding context is still full).

 #KT-43047 Fixed
This commit is contained in:
Alexander Udalov
2020-11-02 18:32:01 +01:00
committed by Alexander Udalov
parent 61548a0a36
commit 106ee1d1ff
12 changed files with 142 additions and 34 deletions
@@ -0,0 +1,25 @@
// This test checks that suppressing conflicting signature / accidental override errors works.
// This is used in libraries for binary-compatible migration, as well as in some cases in multiplatform projects.
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// FILE: box.kt
open class B {
open val s: String
get() = "Fail"
}
class C : B() {
@Suppress("ACCIDENTAL_OVERRIDE")
fun getS(): String = "O"
}
fun box(): String = C().getS() + D().getS()
// FILE: another.kt
@file:Suppress("ACCIDENTAL_OVERRIDE")
class D : B() {
fun getS(): String = "K"
}