FIR: forbid reporting inapplicable-likes on implicit constructors

This commit is contained in:
Mikhail Glukhikh
2021-02-18 12:55:29 +03:00
parent 34c90aab3b
commit 239a44b30c
11 changed files with 16 additions and 27 deletions
@@ -63,5 +63,5 @@ class M {
}
class U : M {
constructor()<!INAPPLICABLE_CANDIDATE!><!>
constructor()
}
@@ -3,16 +3,16 @@ class A(x: Int) {
}
class B : A {
<!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!><!NONE_APPLICABLE!><!>
<!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!>
constructor(z: String) : this()
}
<!SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR!>class C : A(20) {
<!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!><!NONE_APPLICABLE!><!>
<!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!>
constructor(z: String) : this()
}<!>
class D() : A(20) {
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor(x: Int)<!><!NONE_APPLICABLE!><!>
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor(x: Int)<!>
constructor(z: String) : this()
}
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.fir.analysis.collectors.components
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.fir.FirFakeSourceElementKind
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollector
@@ -73,6 +74,9 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect
}
}
if (source.kind == FirFakeSourceElementKind.ImplicitConstructor) {
return
}
val coneDiagnostic = diagnostic.toFirDiagnostic(source)
reporter.report(coneDiagnostic, context)
}
@@ -8,7 +8,7 @@ expect open class A {
}
expect class B : A {
<!EXPLICIT_DELEGATION_CALL_REQUIRED, NONE_APPLICABLE!>constructor(i: Int)<!>
<!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor(i: Int)<!>
constructor() : super("B")
}
@@ -2,7 +2,7 @@
open class B0(x: Int)
class A0 : B0 {
<!INAPPLICABLE_CANDIDATE!>constructor()<!>
constructor()
constructor(x: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>()
}
@@ -26,7 +26,7 @@ open class B2 {
}
class A2 : B2 {
<!EXPLICIT_DELEGATION_CALL_REQUIRED, NONE_APPLICABLE!>constructor()<!>
<!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!>
constructor(x: Int) : <!NONE_APPLICABLE!>super<!>()
}
@@ -37,6 +37,6 @@ open class B3 {
}
class A3 : B3 {
<!HIDDEN!>constructor()<!>
constructor()
constructor(x: Int) : <!HIDDEN!>super<!>()
}
@@ -1,7 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class A(p1: String)
class B() : A("") {
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor(s: String)<!><!INAPPLICABLE_CANDIDATE!><!> {
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class A(p1: String)
@@ -2,6 +2,6 @@ class A {
open inner class Inner
class Nested : Inner {
constructor()<!UNRESOLVED_REFERENCE!><!>
constructor()
}
}
@@ -2,5 +2,5 @@
open class A(p1: String, p2: String, p3: String, p4: String, p5: String)
class B : A {
constructor(s: String)<!INAPPLICABLE_CANDIDATE!><!>
constructor(s: String)
}
@@ -1,10 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class B(x: Double) {
constructor(x: Int): this(1.0)
constructor(x: String): this(1.0)
}
interface C
class A : B, C {
constructor(): <!NONE_APPLICABLE!>super<!>(' ')
<!EXPLICIT_DELEGATION_CALL_REQUIRED, NONE_APPLICABLE!>constructor(x: Int)<!>
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class B(x: Double) {
constructor(x: Int): this(1.0)