diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/expectConstructor.kt b/compiler/fir/analysis-tests/testData/resolve/problems/expectConstructor.kt index b2aecf63c06..8293c2763d0 100644 --- a/compiler/fir/analysis-tests/testData/resolve/problems/expectConstructor.kt +++ b/compiler/fir/analysis-tests/testData/resolve/problems/expectConstructor.kt @@ -7,7 +7,7 @@ expect open class ExpectBase(v: String) expect class ExpectDerived(v: String) : ExpectBase expect open class IOException(message: String, cause: Throwable?) { - constructor(message: String) + constructor(message: String) } expect class EOFException(message: String) : IOException diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirCommonConstructorDelegationIssuesChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirCommonConstructorDelegationIssuesChecker.kt index 4d4385b0c93..8ad7e05fa42 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirCommonConstructorDelegationIssuesChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirCommonConstructorDelegationIssuesChecker.kt @@ -24,6 +24,7 @@ object FirCommonConstructorDelegationIssuesChecker : FirRegularClassChecker() { override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { val cyclicConstructors = mutableSetOf() 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 { diff --git a/compiler/testData/diagnostics/tests/multiplatform/enum/constructorInHeaderEnum.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/enum/constructorInHeaderEnum.fir.kt index d9fd8902af9..a19bd905193 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/enum/constructorInHeaderEnum.fir.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/enum/constructorInHeaderEnum.fir.kt @@ -6,7 +6,7 @@ expect enum class En(x: Int) { E2(42), ; - constructor(s: String) + constructor(s: String) } expect enum class En2 { diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/headerClassWithFunctionBody.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/headerClassWithFunctionBody.fir.kt index 9fc89185797..993e4e8529d 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/headerClass/headerClassWithFunctionBody.fir.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/headerClassWithFunctionBody.fir.kt @@ -8,7 +8,7 @@ expect class Foo( "no" } - constructor(s: String) { + constructor(s: String) { "no" } diff --git a/compiler/testData/diagnostics/tests/multiplatform/namedArguments.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/namedArguments.fir.kt deleted file mode 100644 index a8d37ce595b..00000000000 --- a/compiler/testData/diagnostics/tests/multiplatform/namedArguments.fir.kt +++ /dev/null @@ -1,35 +0,0 @@ -// MODULE: m1-common -// FILE: common.kt - -expect class Foo(zzz: Int) { - 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) -} diff --git a/compiler/testData/diagnostics/tests/multiplatform/namedArguments.kt b/compiler/testData/diagnostics/tests/multiplatform/namedArguments.kt index 25005f2b91f..a8d6ebddec6 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/namedArguments.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/namedArguments.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // MODULE: m1-common // FILE: common.kt