FIR: don't report PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED in exp.cl.
#KT-51761 Fixed
This commit is contained in:
@@ -7,7 +7,7 @@ expect open class ExpectBase(v: String)
|
||||
expect class ExpectDerived(v: String) : ExpectBase
|
||||
|
||||
expect open class IOException(message: String, cause: Throwable?) {
|
||||
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor(message: String)<!>
|
||||
constructor(message: String)
|
||||
}
|
||||
|
||||
expect class EOFException(message: String) : IOException
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@ object FirCommonConstructorDelegationIssuesChecker : FirRegularClassChecker() {
|
||||
override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
val cyclicConstructors = mutableSetOf<FirConstructor>()
|
||||
var hasPrimaryConstructor = false
|
||||
val isEffectivelyExpect = declaration.isEffectivelyExpect(context.containingDeclarations.lastOrNull() as? FirRegularClass, context)
|
||||
|
||||
// secondary; non-cyclic;
|
||||
// candidates for further analysis
|
||||
@@ -47,7 +48,7 @@ object FirCommonConstructorDelegationIssuesChecker : FirRegularClassChecker() {
|
||||
|
||||
if (hasPrimaryConstructor) {
|
||||
for (it in otherConstructors) {
|
||||
if (it.delegatedConstructor?.isThis != true) {
|
||||
if (!isEffectivelyExpect && it.delegatedConstructor?.isThis != true) {
|
||||
if (it.delegatedConstructor?.source != null) {
|
||||
reporter.reportOn(it.delegatedConstructor?.source, FirErrors.PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED, context)
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ expect enum class En(x: Int) {
|
||||
E2(42),
|
||||
;
|
||||
|
||||
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor(s: String)<!>
|
||||
constructor(s: String)
|
||||
}
|
||||
|
||||
expect enum class En2 {
|
||||
|
||||
Vendored
+1
-1
@@ -8,7 +8,7 @@ expect class Foo(
|
||||
"no"
|
||||
}
|
||||
|
||||
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor(s: String)<!> {
|
||||
constructor(s: String) {
|
||||
"no"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect class Foo(zzz: Int) {
|
||||
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor(aaa: Boolean)<!>
|
||||
|
||||
fun f1(xxx: String): String
|
||||
}
|
||||
|
||||
expect fun f2(xxx: Int)
|
||||
|
||||
fun testCommon() {
|
||||
Foo(zzz = 0)
|
||||
val f = Foo(aaa = true)
|
||||
f.f1(xxx = "")
|
||||
f2(xxx = 42)
|
||||
}
|
||||
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual class Foo actual constructor(val aaa: Boolean) {
|
||||
actual constructor(zzz: Int) : this(zzz == 0)
|
||||
|
||||
actual fun f1(xxx: String) = xxx
|
||||
}
|
||||
|
||||
actual fun f2(xxx: Int) {}
|
||||
|
||||
fun testPlatform() {
|
||||
Foo(zzz = 0)
|
||||
val f = Foo(aaa = true)
|
||||
f.f1(xxx = "")
|
||||
f2(xxx = 42)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
|
||||
Reference in New Issue
Block a user