[FIR] Don't report simple diagnostics on fake sources

This commit is contained in:
Mikhail Glukhikh
2020-07-27 12:59:08 +03:00
parent 551bdd267d
commit e0d25876b0
3 changed files with 9 additions and 4 deletions
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.fir.analysis.collectors.components
import org.jetbrains.kotlin.fir.FirFakeSourceElementKind
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollector
@@ -64,7 +65,11 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect
is ConeVariableExpectedError -> FirErrors.VARIABLE_EXPECTED.on(source)
is ConeTypeMismatchError -> FirErrors.TYPE_MISMATCH.on(source, diagnostic.expectedType, diagnostic.actualType)
is ConeUnexpectedTypeArgumentsError -> FirErrors.TYPE_ARGUMENTS_NOT_ALLOWED.on(diagnostic.source.safeAs() ?: source)
is ConeSimpleDiagnostic -> diagnostic.getFactory().on(source)
is ConeSimpleDiagnostic -> if (source.kind is FirFakeSourceElementKind) {
null
} else {
diagnostic.getFactory().on(source)
}
is ConeStubDiagnostic -> null
is ConeIntermediateDiagnostic -> null
else -> throw IllegalArgumentException("Unsupported diagnostic type: ${diagnostic.javaClass}")
@@ -1,6 +1,6 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
data class A(val i: Int, val j: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>G<!>)
data class B(val i: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>G<!>, val j: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>G<!>)
data class A(val i: Int, val j: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>G<!>)
data class B(val i: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>G<!>, val j: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>G<!>)
fun fa(a: A) {
@@ -1,4 +1,4 @@
data class A(val x: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Set<CLassNotFound><!> = setOf()) {
data class A(val x: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Set<CLassNotFound><!> = setOf()) {
fun with(x: <!OTHER_ERROR, OTHER_ERROR!>Set<CLassNotFound>?<!> = null) {
A(x ?: this.x)
}