diff --git a/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/web/common/checkers/declaration/FirWebCommonExternalChecker.kt b/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/web/common/checkers/declaration/FirWebCommonExternalChecker.kt index 6c5da41a68d..0ce19585171 100644 --- a/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/web/common/checkers/declaration/FirWebCommonExternalChecker.kt +++ b/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/web/common/checkers/declaration/FirWebCommonExternalChecker.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.analysis.web.common.checkers.declaration import org.jetbrains.kotlin.* +import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.diagnostics.reportOn @@ -124,7 +125,10 @@ abstract class FirWebCommonExternalChecker(private val allowCompanionInInterface declaration.checkBody(context, reporter) declaration.checkDelegation(context, reporter) declaration.checkAnonymousInitializer(context, reporter) - declaration.checkConstructorPropertyParam(context, reporter) + + if (!context.languageVersionSettings.supportsFeature(LanguageFeature.JsExternalPropertyParameters)) { + declaration.checkConstructorPropertyParam(context, reporter) + } additionalCheck(declaration, context, reporter) } diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassAsParameterOrReturnTypeWhenPropertyParametersAllowed.kt.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassAsParameterOrReturnTypeWhenPropertyParametersAllowed.kt.kt new file mode 100644 index 00000000000..1156f275a8b --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassAsParameterOrReturnTypeWhenPropertyParametersAllowed.kt.kt @@ -0,0 +1,66 @@ +// FIR_IDENTICAL +// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses, -JsAllowValueClassesInExternals, +JsExternalPropertyParameters +// !DIAGNOSTICS: -OPT_IN_USAGE + +// FILE: uint.kt + +package kotlin + +inline class UInt(private val i: Int) + +// FILE: test.kt + +inline class SomeIC(val a: Int) + +external val l: SomeIC + +external val ll + get(): SomeIC = definedExternally + +external var r: SomeIC + +external var rr: SomeIC + get() = definedExternally + set(v: SomeIC) { definedExternally } + +external fun foo(): SomeIC +external fun foo(c: SomeIC): SomeIC +external fun foo(a: Int, c: SomeIC): SomeIC + +external fun foo(a: Int, vararg args: SomeIC) +external fun foo(a: Int, ui: UInt, vararg args: UInt) + +external class CC( + a: SomeIC, + val b: SomeIC, + var c: SomeIC +) { + val l: SomeIC + var r: SomeIC + + fun foo(): SomeIC + fun foo(c: SomeIC): SomeIC + fun foo(a: Int, c: SomeIC): SomeIC + + class N( + a: SomeIC, + val b: SomeIC, + var c: SomeIC + ) { + val l: SomeIC + var r: SomeIC + + fun foo(): SomeIC + fun foo(c: SomeIC): SomeIC + fun foo(a: Int, c: SomeIC): SomeIC + } +} + +external interface EI { + val l: SomeIC + var r: SomeIC + + fun foo(): SomeIC + fun foo(c: SomeIC): SomeIC + fun foo(a: Int, c: SomeIC): SomeIC +} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassAsParameterOrReturnTypeWithPropertyParameters_allowed.kt.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassAsParameterOrReturnTypeWithPropertyParameters_allowed.kt.kt new file mode 100644 index 00000000000..85c6cf0a003 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassAsParameterOrReturnTypeWithPropertyParameters_allowed.kt.kt @@ -0,0 +1,66 @@ +// FIR_IDENTICAL +// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses, +JsAllowValueClassesInExternals, +JsExternalPropertyParameters +// !DIAGNOSTICS: +INLINE_CLASS_IN_EXTERNAL_DECLARATION_WARNING -OPT_IN_USAGE + +// FILE: uint.kt + +package kotlin + +inline class UInt(private val i: Int) + +// FILE: test.kt + +inline class SomeIC(val a: Int) + +external val l: SomeIC + +external val ll + get(): SomeIC = definedExternally + +external var r: SomeIC + +external var rr: SomeIC + get() = definedExternally + set(v: SomeIC) { definedExternally } + +external fun foo(): SomeIC +external fun foo(c: SomeIC): SomeIC +external fun foo(a: Int, c: SomeIC): SomeIC + +external fun foo(a: Int, vararg args: SomeIC) +external fun foo(a: Int, ui: UInt, vararg args: UInt) + +external class CC( + a: SomeIC, + val b: SomeIC, + var c: SomeIC +) { + val l: SomeIC + var r: SomeIC + + fun foo(): SomeIC + fun foo(c: SomeIC): SomeIC + fun foo(a: Int, c: SomeIC): SomeIC + + class N( + a: SomeIC, + val b: SomeIC, + var c: SomeIC + ) { + val l: SomeIC + var r: SomeIC + + fun foo(): SomeIC + fun foo(c: SomeIC): SomeIC + fun foo(a: Int, c: SomeIC): SomeIC + } +} + +external interface EI { + val l: SomeIC + var r: SomeIC + + fun foo(): SomeIC + fun foo(c: SomeIC): SomeIC + fun foo(a: Int, c: SomeIC): SomeIC +} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassWithAllowedPropertyParameter.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassWithAllowedPropertyParameter.kt new file mode 100644 index 00000000000..8548c6577cb --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassWithAllowedPropertyParameter.kt @@ -0,0 +1,11 @@ +// FIR_IDENTICAL +// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses, +JsExternalPropertyParameters +// !DIAGNOSTICS: +ENUM_CLASS_IN_EXTERNAL_DECLARATION_WARNING + +external inline class C(val a: Int) { + fun foo() +} + +inline external enum class E { + A +} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/propertyParameter.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/propertyParameter.kt index 70ef9b6a9ac..bb7be2296ea 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/propertyParameter.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/propertyParameter.kt @@ -1,2 +1,2 @@ // FIR_IDENTICAL -external class C(x: Int, val y: String) \ No newline at end of file +external class C(x: Int, val y: String) diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/propertyParameterWhenItsAllowed.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/propertyParameterWhenItsAllowed.kt new file mode 100644 index 00000000000..e2168547aa9 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/propertyParameterWhenItsAllowed.kt @@ -0,0 +1,4 @@ +// FIR_IDENTICAL +// !LANGUAGE: +JsExternalPropertyParameters + +external class C(x: Int, val y: String) diff --git a/compiler/testData/diagnostics/wasmTests/jsInterop/external.kt b/compiler/testData/diagnostics/wasmTests/jsInterop/external.kt index 936855e0dd7..3a0e07fab38 100644 --- a/compiler/testData/diagnostics/wasmTests/jsInterop/external.kt +++ b/compiler/testData/diagnostics/wasmTests/jsInterop/external.kt @@ -1,5 +1,6 @@ // FIR_IDENTICAL // !DIAGNOSTICS: -INLINE_CLASS_DEPRECATED -NO_TAIL_CALLS_FOUND +// !LANGUAGE: +JsExternalPropertyParameters // Classes @@ -18,9 +19,9 @@ external class C5 { inner class C7 } -external inline class C8(val x: Int) +external inline class C8(val x: Int) -external value class C9(val x: Int) +external value class C9(val x: Int) // Interfaces @@ -54,4 +55,4 @@ external fun foo1(): Int // Property parameters -external class C(x: Int, val y: String) +external class C(x: Int, val y: String) diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index a92cdf42956..ebceaabc1bf 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -310,7 +310,6 @@ enum class LanguageFeature( DfaBooleanVariables(KOTLIN_2_0), // KT-25747 LightweightLambdas(KOTLIN_2_0, kind = OTHER), // KT-45375 ObjCSignatureOverrideAnnotation(KOTLIN_2_0, sinceApiVersion = ApiVersion.KOTLIN_2_0, kind = OTHER), // KT-61323 - // 2.1 ReferencesToSyntheticJavaProperties(KOTLIN_2_1), // KT-8575 @@ -324,6 +323,7 @@ enum class LanguageFeature( ProhibitPrivateOperatorCallInInline(KOTLIN_2_1, kind = BUG_FIX), // KT-65494 ProhibitTypealiasAsCallableQualifierInImport(KOTLIN_2_1, kind = BUG_FIX), // KT-64350 ProhibitConstructorAndSupertypeOnTypealiasWithTypeProjection(KOTLIN_2_1, kind = BUG_FIX), // KT-60305 + JsExternalPropertyParameters(KOTLIN_2_1), // KT-65965 // End of 2.* language features -------------------------------------------------- diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsExternalChecker.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsExternalChecker.kt index d0a1f4dc77b..375850ab7b6 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsExternalChecker.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsExternalChecker.kt @@ -157,7 +157,10 @@ class JsExternalChecker(private val allowCompanionInInterface: Boolean) : Declar checkDelegation(declaration, descriptor, trace) checkAnonymousInitializer(declaration, trace) checkEnumEntry(declaration, trace) - checkConstructorPropertyParam(declaration, descriptor, trace) + + if (!context.languageVersionSettings.supportsFeature(LanguageFeature.JsExternalPropertyParameters)) { + checkConstructorPropertyParam(declaration, descriptor, trace) + } } private fun checkBody( diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsOldFrontendDiagnosticsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsOldFrontendDiagnosticsTestGenerated.java index 30d9cb7b674..9e18285acc2 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsOldFrontendDiagnosticsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsOldFrontendDiagnosticsTestGenerated.java @@ -986,6 +986,18 @@ public class FirLightTreeJsOldFrontendDiagnosticsTestGenerated extends AbstractF runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClass.kt"); } + @Test + @TestMetadata("inlineClassAsParameterOrReturnTypeWhenPropertyParametersAllowed.kt.kt") + public void testInlineClassAsParameterOrReturnTypeWhenPropertyParametersAllowed_kt() { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassAsParameterOrReturnTypeWhenPropertyParametersAllowed.kt.kt"); + } + + @Test + @TestMetadata("inlineClassAsParameterOrReturnTypeWithPropertyParameters_allowed.kt.kt") + public void testInlineClassAsParameterOrReturnTypeWithPropertyParameters_allowed_kt() { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassAsParameterOrReturnTypeWithPropertyParameters_allowed.kt.kt"); + } + @Test @TestMetadata("inlineClassAsParameterOrReturnType_allowed.kt.kt") public void testInlineClassAsParameterOrReturnType_allowed_kt() { @@ -998,6 +1010,12 @@ public class FirLightTreeJsOldFrontendDiagnosticsTestGenerated extends AbstractF runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassAsParameterOrReturnType.kt.kt"); } + @Test + @TestMetadata("inlineClassWithAllowedPropertyParameter.kt") + public void testInlineClassWithAllowedPropertyParameter() { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassWithAllowedPropertyParameter.kt"); + } + @Test @TestMetadata("inlineExtensionToNative.kt") public void testInlineExtensionToNative() { @@ -1040,6 +1058,12 @@ public class FirLightTreeJsOldFrontendDiagnosticsTestGenerated extends AbstractF runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/propertyParameter.kt"); } + @Test + @TestMetadata("propertyParameterWhenItsAllowed.kt") + public void testPropertyParameterWhenItsAllowed() { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/propertyParameterWhenItsAllowed.kt"); + } + @Test @TestMetadata("wrongTarget.kt") public void testWrongTarget() { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsOldFrontendDiagnosticsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsOldFrontendDiagnosticsTestGenerated.java index 7a0415c3628..dccb1c047d9 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsOldFrontendDiagnosticsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsOldFrontendDiagnosticsTestGenerated.java @@ -986,6 +986,18 @@ public class FirPsiJsOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiJ runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClass.kt"); } + @Test + @TestMetadata("inlineClassAsParameterOrReturnTypeWhenPropertyParametersAllowed.kt.kt") + public void testInlineClassAsParameterOrReturnTypeWhenPropertyParametersAllowed_kt() { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassAsParameterOrReturnTypeWhenPropertyParametersAllowed.kt.kt"); + } + + @Test + @TestMetadata("inlineClassAsParameterOrReturnTypeWithPropertyParameters_allowed.kt.kt") + public void testInlineClassAsParameterOrReturnTypeWithPropertyParameters_allowed_kt() { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassAsParameterOrReturnTypeWithPropertyParameters_allowed.kt.kt"); + } + @Test @TestMetadata("inlineClassAsParameterOrReturnType_allowed.kt.kt") public void testInlineClassAsParameterOrReturnType_allowed_kt() { @@ -998,6 +1010,12 @@ public class FirPsiJsOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiJ runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassAsParameterOrReturnType.kt.kt"); } + @Test + @TestMetadata("inlineClassWithAllowedPropertyParameter.kt") + public void testInlineClassWithAllowedPropertyParameter() { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassWithAllowedPropertyParameter.kt"); + } + @Test @TestMetadata("inlineExtensionToNative.kt") public void testInlineExtensionToNative() { @@ -1040,6 +1058,12 @@ public class FirPsiJsOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiJ runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/propertyParameter.kt"); } + @Test + @TestMetadata("propertyParameterWhenItsAllowed.kt") + public void testPropertyParameterWhenItsAllowed() { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/propertyParameterWhenItsAllowed.kt"); + } + @Test @TestMetadata("wrongTarget.kt") public void testWrongTarget() { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/DiagnosticsWithJsStdLibTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/DiagnosticsWithJsStdLibTestGenerated.java index b3ab887b8a9..dd3f1d80ddf 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/DiagnosticsWithJsStdLibTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/DiagnosticsWithJsStdLibTestGenerated.java @@ -986,6 +986,18 @@ public class DiagnosticsWithJsStdLibTestGenerated extends AbstractDiagnosticsTes runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClass.kt"); } + @Test + @TestMetadata("inlineClassAsParameterOrReturnTypeWhenPropertyParametersAllowed.kt.kt") + public void testInlineClassAsParameterOrReturnTypeWhenPropertyParametersAllowed_kt() { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassAsParameterOrReturnTypeWhenPropertyParametersAllowed.kt.kt"); + } + + @Test + @TestMetadata("inlineClassAsParameterOrReturnTypeWithPropertyParameters_allowed.kt.kt") + public void testInlineClassAsParameterOrReturnTypeWithPropertyParameters_allowed_kt() { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassAsParameterOrReturnTypeWithPropertyParameters_allowed.kt.kt"); + } + @Test @TestMetadata("inlineClassAsParameterOrReturnType_allowed.kt.kt") public void testInlineClassAsParameterOrReturnType_allowed_kt() { @@ -998,6 +1010,12 @@ public class DiagnosticsWithJsStdLibTestGenerated extends AbstractDiagnosticsTes runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassAsParameterOrReturnType.kt.kt"); } + @Test + @TestMetadata("inlineClassWithAllowedPropertyParameter.kt") + public void testInlineClassWithAllowedPropertyParameter() { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/inlineClassWithAllowedPropertyParameter.kt"); + } + @Test @TestMetadata("inlineExtensionToNative.kt") public void testInlineExtensionToNative() { @@ -1040,6 +1058,12 @@ public class DiagnosticsWithJsStdLibTestGenerated extends AbstractDiagnosticsTes runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/propertyParameter.kt"); } + @Test + @TestMetadata("propertyParameterWhenItsAllowed.kt") + public void testPropertyParameterWhenItsAllowed() { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/native/propertyParameterWhenItsAllowed.kt"); + } + @Test @TestMetadata("wrongTarget.kt") public void testWrongTarget() {