[FIR] Don't report duplicated errors in implicit primary constructors
This commit is contained in:
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
// FILE: K1.kt
|
// FILE: K1.kt
|
||||||
class K2: J1() {
|
class K2: J1() {
|
||||||
class Q : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Nested<!>()
|
class Q : <!OTHER_ERROR!>Nested<!>()
|
||||||
fun bar() {
|
fun bar() {
|
||||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||||
<!UNRESOLVED_REFERENCE!>baz<!>()
|
<!UNRESOLVED_REFERENCE!>baz<!>()
|
||||||
|
|||||||
+10
-3
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollector
|
|||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticFactory0
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticFactory0
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
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.FirErrorFunction
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
|
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
|
||||||
import org.jetbrains.kotlin.fir.diagnostics.*
|
import org.jetbrains.kotlin.fir.diagnostics.*
|
||||||
@@ -31,9 +32,15 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef, data: CheckerContext) {
|
override fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef, data: CheckerContext) {
|
||||||
if (data.containingDeclarations.lastOrNull() is FirDefaultPropertyAccessor) {
|
when (val lastContainingDeclaration = data.containingDeclarations.lastOrNull()) {
|
||||||
// It always uses the same type ref as the corresponding property
|
is FirDefaultPropertyAccessor -> {
|
||||||
return
|
// It always uses the same type ref as the corresponding property
|
||||||
|
return
|
||||||
|
}
|
||||||
|
is FirConstructor -> if (lastContainingDeclaration.source?.kind is FirFakeSourceElementKind) {
|
||||||
|
// Implicit primary constructor uses the same type ref as the corresponding property
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val source = errorTypeRef.source ?: return
|
val source = errorTypeRef.source ?: return
|
||||||
runCheck { reportFirDiagnostic(errorTypeRef.diagnostic, source, it) }
|
runCheck { reportFirDiagnostic(errorTypeRef.diagnostic, source, it) }
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ public class C {
|
|||||||
|
|
||||||
open class Base ()
|
open class Base ()
|
||||||
|
|
||||||
class Foo : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Data<!>()
|
class Foo : <!OTHER_ERROR!>Data<!>()
|
||||||
|
|
||||||
companion object : DerivedAbstract()
|
companion object : DerivedAbstract()
|
||||||
}
|
}
|
||||||
+1
-1
@@ -9,7 +9,7 @@ public class C {
|
|||||||
|
|
||||||
open class Base ()
|
open class Base ()
|
||||||
|
|
||||||
class Foo : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Data<!>()
|
class Foo : <!OTHER_ERROR!>Data<!>()
|
||||||
|
|
||||||
companion object : DerivedAbstract()
|
companion object : DerivedAbstract()
|
||||||
}
|
}
|
||||||
+3
-3
@@ -51,11 +51,11 @@ interface MessageManager9 : Manager<Message3> {
|
|||||||
fun <T : Message3> execute4() {}
|
fun <T : Message3> execute4() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
object MessageManager10 : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Message5<Int><!>() {
|
object MessageManager10 : <!OTHER_ERROR!>Message5<Int><!>() {
|
||||||
fun <T : Int> execute() {}
|
fun <T : Int> execute() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MessageManager11<A> : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Message5<Message5<A>><!>() {
|
class MessageManager11<A> : <!OTHER_ERROR!>Message5<Message5<A>><!>() {
|
||||||
fun <T : <!OTHER_ERROR!>Message5<A><!>> execute() {}
|
fun <T : <!OTHER_ERROR!>Message5<A><!>> execute() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ data class MessageManager12(val x: Int) : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERRO
|
|||||||
fun <T : Message2> execute() {}
|
fun <T : Message2> execute() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class MessageManager13<A> : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Message5<A><!>() {
|
sealed class MessageManager13<A> : <!OTHER_ERROR!>Message5<A><!>() {
|
||||||
fun <T : A> execute() {}
|
fun <T : A> execute() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
package typeReferenceError
|
package typeReferenceError
|
||||||
|
|
||||||
class Pair<<!SYNTAX!><!>:<!UNRESOLVED_REFERENCE!>(val c: <!SYNTAX!><!SYNTAX!><!>fun<!><!SYNTAX!><!> <!OTHER_ERROR, OTHER_ERROR!>main<!><!>()
|
class Pair<<!SYNTAX!><!>:<!UNRESOLVED_REFERENCE!>(val c: <!SYNTAX!><!SYNTAX!><!>fun<!><!SYNTAX!><!> <!OTHER_ERROR!>main<!><!>()
|
||||||
+14
-14
@@ -73,28 +73,28 @@ open class C : O.B() {
|
|||||||
open class n : FromCompanionC()
|
open class n : FromCompanionC()
|
||||||
|
|
||||||
// INVISIBLE: direct superclasses themselves.
|
// INVISIBLE: direct superclasses themselves.
|
||||||
open class a : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>A<!>()
|
open class a : <!OTHER_ERROR!>A<!>()
|
||||||
open class b : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>B<!>()
|
open class b : <!OTHER_ERROR!>B<!>()
|
||||||
|
|
||||||
// DEPRECATED: Classifiers from companions of direct superclasses
|
// DEPRECATED: Classifiers from companions of direct superclasses
|
||||||
open class e : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromCompanionA<!>()
|
open class e : <!OTHER_ERROR!>FromCompanionA<!>()
|
||||||
open class f : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromCompanionB<!>()
|
open class f : <!OTHER_ERROR!>FromCompanionB<!>()
|
||||||
|
|
||||||
// INVISIBLE: "cousin" supertypes themselves
|
// INVISIBLE: "cousin" supertypes themselves
|
||||||
open class g : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Alpha<!>()
|
open class g : <!OTHER_ERROR!>Alpha<!>()
|
||||||
open class h : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Beta<!>()
|
open class h : <!OTHER_ERROR!>Beta<!>()
|
||||||
open class i : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Gamma<!>()
|
open class i : <!OTHER_ERROR!>Gamma<!>()
|
||||||
|
|
||||||
// DEPRECATED: classifiers from "cousin" superclasses
|
// DEPRECATED: classifiers from "cousin" superclasses
|
||||||
open class k : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromAlpha<!>()
|
open class k : <!OTHER_ERROR!>FromAlpha<!>()
|
||||||
open class l : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromBeta<!>()
|
open class l : <!OTHER_ERROR!>FromBeta<!>()
|
||||||
open class m : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromGamma<!>()
|
open class m : <!OTHER_ERROR!>FromGamma<!>()
|
||||||
|
|
||||||
// INVISIBLE: We don't see classifiers from companions of "cousin" superclasses
|
// INVISIBLE: We don't see classifiers from companions of "cousin" superclasses
|
||||||
open class o : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromCompanionAlpha<!>()
|
open class o : <!OTHER_ERROR!>FromCompanionAlpha<!>()
|
||||||
open class p : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromCompanionBeta<!>()
|
open class p : <!OTHER_ERROR!>FromCompanionBeta<!>()
|
||||||
open class q : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromCompanionGamma<!>()
|
open class q : <!OTHER_ERROR!>FromCompanionGamma<!>()
|
||||||
|
|
||||||
// DEPRECATED: Classifiers from supertypes of our own companion
|
// DEPRECATED: Classifiers from supertypes of our own companion
|
||||||
open class r : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromDelta<!>()
|
open class r : <!OTHER_ERROR!>FromDelta<!>()
|
||||||
}
|
}
|
||||||
+14
-14
@@ -73,28 +73,28 @@ open class C : O.B() {
|
|||||||
open class n : FromCompanionC()
|
open class n : FromCompanionC()
|
||||||
|
|
||||||
// INVISIBLE: direct superclasses themselves.
|
// INVISIBLE: direct superclasses themselves.
|
||||||
open class a : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>A<!>()
|
open class a : <!OTHER_ERROR!>A<!>()
|
||||||
open class b : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>B<!>()
|
open class b : <!OTHER_ERROR!>B<!>()
|
||||||
|
|
||||||
// DEPRECATED: Classifiers from companions of direct superclasses
|
// DEPRECATED: Classifiers from companions of direct superclasses
|
||||||
open class e : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromCompanionA<!>()
|
open class e : <!OTHER_ERROR!>FromCompanionA<!>()
|
||||||
open class f : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromCompanionB<!>()
|
open class f : <!OTHER_ERROR!>FromCompanionB<!>()
|
||||||
|
|
||||||
// INVISIBLE: "cousin" supertypes themselves
|
// INVISIBLE: "cousin" supertypes themselves
|
||||||
open class g : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Alpha<!>()
|
open class g : <!OTHER_ERROR!>Alpha<!>()
|
||||||
open class h : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Beta<!>()
|
open class h : <!OTHER_ERROR!>Beta<!>()
|
||||||
open class i : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Gamma<!>()
|
open class i : <!OTHER_ERROR!>Gamma<!>()
|
||||||
|
|
||||||
// DEPRECATED: classifiers from "cousin" superclasses
|
// DEPRECATED: classifiers from "cousin" superclasses
|
||||||
open class k : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromAlpha<!>()
|
open class k : <!OTHER_ERROR!>FromAlpha<!>()
|
||||||
open class l : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromBeta<!>()
|
open class l : <!OTHER_ERROR!>FromBeta<!>()
|
||||||
open class m : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromGamma<!>()
|
open class m : <!OTHER_ERROR!>FromGamma<!>()
|
||||||
|
|
||||||
// INVISIBLE: We don't see classifiers from companions of "cousin" superclasses
|
// INVISIBLE: We don't see classifiers from companions of "cousin" superclasses
|
||||||
open class o : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromCompanionAlpha<!>()
|
open class o : <!OTHER_ERROR!>FromCompanionAlpha<!>()
|
||||||
open class p : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromCompanionBeta<!>()
|
open class p : <!OTHER_ERROR!>FromCompanionBeta<!>()
|
||||||
open class q : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromCompanionGamma<!>()
|
open class q : <!OTHER_ERROR!>FromCompanionGamma<!>()
|
||||||
|
|
||||||
// DEPRECATED: Classifiers from supertypes of our own companion
|
// DEPRECATED: Classifiers from supertypes of our own companion
|
||||||
open class r : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>FromDelta<!>()
|
open class r : <!OTHER_ERROR!>FromDelta<!>()
|
||||||
}
|
}
|
||||||
+1
-1
@@ -42,7 +42,7 @@ class Derived : Base() {
|
|||||||
<!UNRESOLVED_REFERENCE!>syntheticProperty<!> = 42
|
<!UNRESOLVED_REFERENCE!>syntheticProperty<!> = 42
|
||||||
}
|
}
|
||||||
|
|
||||||
class JavaStaticInSupertypeList : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Classifier<!>() {
|
class JavaStaticInSupertypeList : <!OTHER_ERROR!>Classifier<!>() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ class Derived : Base() {
|
|||||||
<!UNRESOLVED_REFERENCE!>syntheticProperty<!> = 42
|
<!UNRESOLVED_REFERENCE!>syntheticProperty<!> = 42
|
||||||
}
|
}
|
||||||
|
|
||||||
class JavaStaticInSupertypeList : <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Classifier<!>() {
|
class JavaStaticInSupertypeList : <!OTHER_ERROR!>Classifier<!>() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,4 +11,4 @@ interface E2<T : <!TYPE_ARGUMENTS_NOT_ALLOWED!>D<A><!>, D<!SYNTAX!><<!><!SYNTAX!
|
|||||||
|
|
||||||
open class L<E>()
|
open class L<E>()
|
||||||
|
|
||||||
class M<C> : L<<!TYPE_ARGUMENTS_NOT_ALLOWED, TYPE_ARGUMENTS_NOT_ALLOWED, TYPE_ARGUMENTS_NOT_ALLOWED!>C<C><!>>()
|
class M<C> : L<<!TYPE_ARGUMENTS_NOT_ALLOWED!>C<C><!>>()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import d
|
|||||||
import d.Test
|
import d.Test
|
||||||
import b.d
|
import b.d
|
||||||
|
|
||||||
class Some: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Test<!>()
|
class Some: <!OTHER_ERROR!>Test<!>()
|
||||||
|
|
||||||
//FILE:b.kt
|
//FILE:b.kt
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user