[FIR] Don't report duplicated errors in implicit properties / parameters

This commit is contained in:
Mikhail Glukhikh
2020-07-27 13:30:15 +03:00
parent ceaffb1e8b
commit 9335e09149
9 changed files with 27 additions and 17 deletions
@@ -14,6 +14,8 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticFactory0
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
import org.jetbrains.kotlin.fir.declarations.FirConstructor
import org.jetbrains.kotlin.fir.declarations.FirErrorFunction
import org.jetbrains.kotlin.fir.declarations.FirProperty
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
import org.jetbrains.kotlin.fir.diagnostics.*
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind.*
@@ -41,6 +43,14 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect
// Implicit primary constructor uses the same type ref as the corresponding property
return
}
is FirValueParameter -> if (lastContainingDeclaration.source?.kind is FirFakeSourceElementKind) {
// Value parameter of default setter uses the same type ref as the corresponding property
return
}
is FirProperty -> if (lastContainingDeclaration.source?.kind is FirFakeSourceElementKind) {
// Properties of implicit primary constructor uses the same type ref as the corresponding value parameter
return
}
}
val source = errorTypeRef.source ?: return
runCheck { reportFirDiagnostic(errorTypeRef.diagnostic, source, it) }
+1 -1
View File
@@ -7,7 +7,7 @@ enum class Color {
}
}
class MyColor(val x: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Color.RED<!>, y: <!OTHER_ERROR!>Color.RED<!>) : <!OTHER_ERROR!>Color.RED<!> {
class MyColor(val x: <!OTHER_ERROR!>Color.RED<!>, y: <!OTHER_ERROR!>Color.RED<!>) : <!OTHER_ERROR!>Color.RED<!> {
var z: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Color.RED<!> = Color.RED
set(arg: Color.RED) { z = arg }
@@ -34,7 +34,7 @@ annotation class Ann8(val p1: Array<String>,
val p4: Array<Ann1>)
annotation class Ann9(
val error: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Unresolved<!> = <!UNRESOLVED_REFERENCE!>Unresolved<!>.<!UNRESOLVED_REFERENCE!>VALUE<!>
val error: <!OTHER_ERROR!>Unresolved<!> = <!UNRESOLVED_REFERENCE!>Unresolved<!>.<!UNRESOLVED_REFERENCE!>VALUE<!>
)
@@ -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!>G<!>)
data class B(val i: <!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!>G<!>)
data class A(val i: Int, val j: <!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!>G<!>, val j: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>G<!>)
fun fa(a: A) {
@@ -12,10 +12,10 @@ inline class ULong(private val l: Long)
// FILE: test.kt
annotation class AnnoUB(val ub0: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>UByte<!>, val ub1: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>UByte<!>)
annotation class AnnoUS(val us0: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>UShort<!>, val us1: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>UShort<!>)
annotation class AnnoUI(val ui0: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>UInt<!>, val ui1: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>UInt<!>, val ui2: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>UInt<!>, val ui3: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>UInt<!>)
annotation class AnnoUL(val ul0: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>ULong<!>, val ul1: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>ULong<!>)
annotation class AnnoUB(val ub0: <!OTHER_ERROR!>UByte<!>, val ub1: <!OTHER_ERROR!>UByte<!>)
annotation class AnnoUS(val us0: <!OTHER_ERROR!>UShort<!>, val us1: <!OTHER_ERROR!>UShort<!>)
annotation class AnnoUI(val ui0: <!OTHER_ERROR!>UInt<!>, val ui1: <!OTHER_ERROR!>UInt<!>, val ui2: <!OTHER_ERROR!>UInt<!>, val ui3: <!OTHER_ERROR!>UInt<!>)
annotation class AnnoUL(val ul0: <!OTHER_ERROR!>ULong<!>, val ul1: <!OTHER_ERROR!>ULong<!>)
const val ub0 = <!UNRESOLVED_REFERENCE!>UByte<!>(1)
const val us0 = <!UNRESOLVED_REFERENCE!>UShort<!>(2)
@@ -41,4 +41,4 @@ const val explicit: <!OTHER_ERROR!>UInt<!> = <!UNRESOLVED_REFERENCE!>UInt<!>(2)
const val nullable: <!OTHER_ERROR!>UInt?<!> = <!UNRESOLVED_REFERENCE!>UInt<!>(3)
annotation class NullableAnno(val u: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>UInt?<!>)
annotation class NullableAnno(val u: <!OTHER_ERROR!>UInt?<!>)
@@ -4,7 +4,7 @@ class Cell<TC>(val x: TC)
fun <T> id(x: T): T {
typealias C = Cell<T>
class Local(val cell: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>C<!>)
class Local(val cell: <!OTHER_ERROR, OTHER_ERROR!>C<!>)
val cx = <!UNRESOLVED_REFERENCE!>C<!>(x)
val c: <!OTHER_ERROR, OTHER_ERROR!>C<!> = Local(cx).cell
return c.<!UNRESOLVED_REFERENCE!>x<!>
@@ -38,10 +38,10 @@ interface Test<in I, out O, P> {
var neOk22: Inv<out O>
var neOk23: Inv<out I>
var neOk30: <!OTHER_ERROR, OTHER_ERROR!>Pair<I, ><!>
var neOk31: <!OTHER_ERROR, OTHER_ERROR!>Pair<I, Inv><!>
var neOk32: <!OTHER_ERROR, OTHER_ERROR!>Inv<!>
var neOk30: <!OTHER_ERROR!>Pair<I, ><!>
var neOk31: <!OTHER_ERROR!>Pair<I, Inv><!>
var neOk32: <!OTHER_ERROR!>Inv<!>
var neOk33: Inv<<!SYNTAX!><!>>
var neOk34: <!OTHER_ERROR, OTHER_ERROR!>Inv<C><!>
var neOk35: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS, WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<P, P><!>
var neOk34: <!OTHER_ERROR!>Inv<C><!>
var neOk35: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<P, P><!>
}
@@ -3,7 +3,7 @@
interface Inv
class Impl : Inv
class Scope<InterfaceT, ImplementationT : InterfaceT>(private val implClass: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>j.Class<ImplementationT><!>) {
class Scope<InterfaceT, ImplementationT : InterfaceT>(private val implClass: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>j.Class<ImplementationT><!>) {
fun foo(c: Collection<InterfaceT>) {
val hm = c.asSequence()
.<!INAPPLICABLE_CANDIDATE!>filter<!>(<!UNRESOLVED_REFERENCE!>implClass::isInstance<!>)
@@ -1,4 +1,4 @@
data class A(val x: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Set<CLassNotFound><!> = setOf()) {
data class A(val x: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Set<CLassNotFound><!> = setOf()) {
fun with(x: <!OTHER_ERROR, OTHER_ERROR!>Set<CLassNotFound>?<!> = null) {
A(x ?: this.x)
}