FIR: Report EXPLICIT_DELEGATION_CALL_REQUIRED in some missing cases

^KT-55877 Fixed
This commit is contained in:
Kirill Rakhman
2023-01-26 11:25:58 +01:00
committed by Space Team
parent 91f68f0e17
commit efc957586d
6 changed files with 7 additions and 15 deletions
@@ -63,5 +63,5 @@ open class M {
} }
class U : M { class U : M {
constructor() <!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!>
} }
@@ -13,8 +13,8 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
import org.jetbrains.kotlin.fir.declarations.FirConstructor import org.jetbrains.kotlin.fir.declarations.FirConstructor
import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.FirRegularClass
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnosticHolder
import org.jetbrains.kotlin.fir.references.* import org.jetbrains.kotlin.fir.references.*
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeAmbiguityError
import org.jetbrains.kotlin.fir.symbols.SymbolInternals import org.jetbrains.kotlin.fir.symbols.SymbolInternals
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
import org.jetbrains.kotlin.utils.addToStdlib.lastIsInstanceOrNull import org.jetbrains.kotlin.utils.addToStdlib.lastIsInstanceOrNull
@@ -59,11 +59,8 @@ object FirCommonConstructorDelegationIssuesChecker : FirRegularClassChecker() {
} }
} else { } else {
for (it in otherConstructors) { for (it in otherConstructors) {
val callee = it.delegatedConstructor?.calleeReference
// couldn't find proper super() constructor implicitly // couldn't find proper super() constructor implicitly
if ( if (it.delegatedConstructor?.calleeReference is FirDiagnosticHolder &&
callee is FirErrorNamedReference && callee.diagnostic is ConeAmbiguityError &&
it.delegatedConstructor?.source?.kind is KtFakeSourceElementKind it.delegatedConstructor?.source?.kind is KtFakeSourceElementKind
) { ) {
reporter.reportOn(it.source, FirErrors.EXPLICIT_DELEGATION_CALL_REQUIRED, context) reporter.reportOn(it.source, FirErrors.EXPLICIT_DELEGATION_CALL_REQUIRED, context)
@@ -2,7 +2,7 @@
open class B0(x: Int) open class B0(x: Int)
class A0 : B0 { class A0 : B0 {
constructor() <!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!>
constructor(x: Int) : <!NO_VALUE_FOR_PARAMETER!>super<!>() constructor(x: Int) : <!NO_VALUE_FOR_PARAMETER!>super<!>()
} }
@@ -37,6 +37,6 @@ open class B3 {
} }
class A3 : B3 { class A3 : B3 {
constructor() <!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!>
constructor(x: Int) : <!INVISIBLE_REFERENCE!>super<!>() constructor(x: Int) : <!INVISIBLE_REFERENCE!>super<!>()
} }
@@ -2,6 +2,6 @@ class A {
open inner class Inner open inner class Inner
class Nested : Inner { class Nested : Inner {
constructor() <!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!>
} }
} }
@@ -1,6 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class A(p1: String, p2: String, p3: String, p4: String, p5: String)
class B : A {
constructor(s: String)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER // !DIAGNOSTICS: -UNUSED_PARAMETER
open class A(p1: String, p2: String, p3: String, p4: String, p5: String) open class A(p1: String, p2: String, p3: String, p4: String, p5: String)