K2: Set correct containingFile in CheckerContext

Previously, it was working for all the checkers but the file-level
DeclarationChecker's because when execution comes to
DeclarationCheck::check for a file, `containingDeclarations` is empty
(it doesn't contain the file itself yet), thus some things that rely on
CheckerContext::containingFile don't work properly.

For example, SimpleDiagnosticsCollectorWithSuppress.report that
effectively doesn't collect diagnostics when the containingFile is null.
This commit is contained in:
Denis.Zharkov
2023-02-08 08:26:09 +01:00
committed by Space Team
parent 970d4f2949
commit a71251d856
6 changed files with 54 additions and 7 deletions
@@ -121,7 +121,7 @@ internal object FileDiagnosticRetriever : FileStructureElementDiagnosticRetrieve
) {
override fun visitFile(file: FirFile, data: Nothing?) {
withAnnotationContainer(file) {
visitWithDeclaration(file) {
visitWithFile(file) {
file.annotations.forEach { it.accept(this, data) }
file.packageDirective.accept(this, data)
file.imports.forEach { it.accept(this, data) }