Tests: do not report backend diagnostics if there's frontend error

In most affected tests, the backend diagnostic such as "conflicting JVM
signature" or "accidental override" is directly caused by some already
existing error reported by frontend, so it doesn't make sense to check
backend diagnostics there.

Tests where that was not the case were moved/copied to
`testsWithJvmBackend`.
This commit is contained in:
Alexander Udalov
2024-03-11 22:22:03 +01:00
committed by Space Team
parent dca6c21d7f
commit 55f9f74d5c
38 changed files with 396 additions and 397 deletions
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.getJvmSignatureDiagnostics
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.diagnostics.Severity
import org.jetbrains.kotlin.platform.jvm.isJvm
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtFile
@@ -44,9 +45,8 @@ class ClassicDiagnosticsHandler(testServices: TestServices) : ClassicFrontendAna
private val reporter = ClassicDiagnosticReporter(testServices)
@OptIn(ExperimentalStdlibApi::class)
override fun processModule(module: TestModule, info: ClassicFrontendOutputArtifact) {
var allDiagnostics = info.analysisResult.bindingContext.diagnostics + computeJvmSignatureDiagnostics(info)
var allDiagnostics = info.analysisResult.bindingContext.diagnostics.toList()
if (AdditionalFilesDirectives.CHECK_TYPE in module.directives) {
allDiagnostics = allDiagnostics.filter { it.factory.name != Errors.UNDERSCORE_USAGE_WITHOUT_BACKTICKS.name }
}
@@ -54,6 +54,10 @@ class ClassicDiagnosticsHandler(testServices: TestServices) : ClassicFrontendAna
allDiagnostics = allDiagnostics.filter { it.factory.name != Errors.NEWER_VERSION_IN_SINCE_KOTLIN.name }
}
if (allDiagnostics.none { it.severity == Severity.ERROR }) {
allDiagnostics = allDiagnostics + computeJvmSignatureDiagnostics(info)
}
val diagnosticsPerFile = allDiagnostics.groupBy { it.psiFile }
val withNewInferenceModeEnabled = testServices.withNewInferenceModeEnabled()
val configuration = reporter.createConfiguration(module)