[FIR] Report conflicts for constructors of top-level classes
^KT-59880
This commit is contained in:
committed by
Space Team
parent
bc2eb546b4
commit
09436d0480
+2
-2
@@ -7,8 +7,8 @@ class B : A {
|
||||
constructor(z: String) : this()
|
||||
}
|
||||
|
||||
<!SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR!>class C : A(20) {
|
||||
<!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!>
|
||||
<!SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR!>class <!CONFLICTING_OVERLOADS!>C<!> : A(20) {
|
||||
<!CONFLICTING_OVERLOADS, EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!>
|
||||
constructor(z: String) : <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>()
|
||||
}<!>
|
||||
|
||||
|
||||
+2
-2
@@ -6,6 +6,6 @@ class D : <!NO_VALUE_FOR_PARAMETER, SUPERTYPE_NOT_INITIALIZED!>C<!>
|
||||
class E : C(10)
|
||||
class F() : C(10)
|
||||
|
||||
<!SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR!>class G : C(10) {
|
||||
constructor() : super(1)
|
||||
<!SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR!>class <!CONFLICTING_OVERLOADS!>G<!> : C(10) {
|
||||
<!CONFLICTING_OVERLOADS!>constructor()<!> : super(1)
|
||||
}<!>
|
||||
|
||||
+13
@@ -161,6 +161,19 @@ fun FirDeclarationCollector<FirBasedSymbol<*>>.collectClassMembers(klass: FirReg
|
||||
}
|
||||
}
|
||||
|
||||
// Constructors of nested classes
|
||||
// are collected when checking the outer
|
||||
// class: this is because they may clash
|
||||
// with functions from this outer class,
|
||||
// so we should avoid checking them twice.
|
||||
if (context.isTopLevel) {
|
||||
scope.processDeclaredConstructors {
|
||||
if (it.isCollectable() && it.isVisibleInClass(klass)) {
|
||||
collect(it, FirRedeclarationPresenter.represent(it, klass), functionDeclarations)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val visitedProperties = mutableSetOf<FirVariableSymbol<*>>()
|
||||
|
||||
scope.collectLeafProperties().forEach {
|
||||
|
||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
open class B(x: Int)
|
||||
<!SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR!>class A : B(1) {
|
||||
constructor(): super(1)
|
||||
<!SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR!>class <!CONFLICTING_OVERLOADS!>A<!> : B(1) {
|
||||
<!CONFLICTING_OVERLOADS!>constructor()<!>: super(1)
|
||||
}<!>
|
||||
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class A(x: String = "", y: String = "") {
|
||||
constructor(x: String, y: String): <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>(x, y)
|
||||
constructor(): <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "")
|
||||
constructor(): <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "")
|
||||
}
|
||||
|
||||
class B {
|
||||
<!CONFLICTING_OVERLOADS!>constructor(x: Int)<!>
|
||||
}
|
||||
|
||||
<!CONFLICTING_OVERLOADS!>fun B(x: Int)<!> {}
|
||||
|
||||
class Outer {
|
||||
class A<!CONFLICTING_OVERLOADS!>(x: String = "", y: String = "")<!> {
|
||||
<!CONFLICTING_OVERLOADS!>constructor(x: String, y: String)<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>(x, y)
|
||||
<!CONFLICTING_OVERLOADS!>constructor()<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "")
|
||||
<!CONFLICTING_OVERLOADS!>constructor()<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "")
|
||||
}
|
||||
|
||||
class B {
|
||||
<!CONFLICTING_OVERLOADS!>constructor(x: Int)<!>
|
||||
}
|
||||
|
||||
<!CONFLICTING_OVERLOADS!>fun B(x: Int)<!> {}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class A<!CONFLICTING_OVERLOADS!>(x: String = "", y: String = "")<!> {
|
||||
|
||||
Reference in New Issue
Block a user