Files
kotlin-fork/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructors.fir.kt
T
Kirill Rakhman 592baee852 [FIR] When call candidates resolve to errors, select the least bad ones
This fixes a scenario when INVISIBLE_REFERENCE is suppressed, but we
resolved to the wrong overload because when none of the candidates were
applicable, more or less the first one was chosen.

Because we call `fullyProcessCandidate` on the candidates, their
applicability can change which can lead to a situation where the
applicability of a ConeAmbiguityError is different to all its
candidates. The changes in coneDiagnosticToFirDiagnostic.kt account for
that, otherwise code like candidates.first { it.applicability ==
CandidateApplicability.UNSAFE_CALL } can throw NoSuchElementException.

#KT-57776 Fixed
2023-04-12 14:03:39 +00:00

23 lines
455 B
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_PARAMETER
open class A protected constructor(x: Int) {
protected constructor() : this(1)
protected constructor(x: String) : this(2)
public constructor(x: Double) : this(3)
}
fun foo() {
<!INVISIBLE_REFERENCE!>A<!>()
A(1.0)
}
class B1 : A(1) {}
class B2 : A() {}
class B3 : A("") {}
class B4 : A {
constructor() : super(1)
constructor(x: Int) : super()
constructor(x: Int, y: Int) : super("")
}