KMP: Put "prohibit expect/actual tailrec/external" under the flag
^KT-61668 Fixed Review: https://jetbrains.team/p/kt/reviews/12062/timeline
This commit is contained in:
+12
@@ -145,6 +145,12 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/expectExternal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("expectExternal_oldLanguageVersion.kt")
|
||||
public void testExpectExternal_oldLanguageVersion() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/expectExternal_oldLanguageVersion.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("expectInterfaceApplicability.kt")
|
||||
public void testExpectInterfaceApplicability() throws Exception {
|
||||
@@ -175,6 +181,12 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/expectTailrec.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("expectTailrec_oldLanguageVersion.kt")
|
||||
public void testExpectTailrec_oldLanguageVersion() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/expectTailrec_oldLanguageVersion.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("headerFunInNonHeaderClass.kt")
|
||||
public void testHeaderFunInNonHeaderClass() throws Exception {
|
||||
|
||||
+12
@@ -145,6 +145,12 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/expectExternal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("expectExternal_oldLanguageVersion.kt")
|
||||
public void testExpectExternal_oldLanguageVersion() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/expectExternal_oldLanguageVersion.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("expectInterfaceApplicability.kt")
|
||||
public void testExpectInterfaceApplicability() throws Exception {
|
||||
@@ -175,6 +181,12 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/expectTailrec.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("expectTailrec_oldLanguageVersion.kt")
|
||||
public void testExpectTailrec_oldLanguageVersion() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/expectTailrec_oldLanguageVersion.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("headerFunInNonHeaderClass.kt")
|
||||
public void testHeaderFunInNonHeaderClass() throws Exception {
|
||||
|
||||
+6
-2
@@ -76,7 +76,9 @@ object FirExpectActualDeclarationChecker : FirBasicDeclarationChecker() {
|
||||
if (declaration is FirProperty) {
|
||||
checkExpectPropertyAccessorsModifiers(declaration, context, reporter)
|
||||
}
|
||||
if (declaration is FirFunction && declaration.isTailRec) {
|
||||
if (context.languageVersionSettings.supportsFeature(LanguageFeature.MultiplatformRestrictions) &&
|
||||
declaration is FirFunction && declaration.isTailRec
|
||||
) {
|
||||
reporter.reportOn(declaration.source, FirErrors.EXPECTED_TAILREC_FUNCTION, context)
|
||||
}
|
||||
}
|
||||
@@ -108,7 +110,9 @@ object FirExpectActualDeclarationChecker : FirBasicDeclarationChecker() {
|
||||
context: CheckerContext,
|
||||
reporter: DiagnosticReporter,
|
||||
) {
|
||||
if (declaration.isExternal) {
|
||||
if (context.languageVersionSettings.supportsFeature(LanguageFeature.MultiplatformRestrictions) &&
|
||||
declaration.isExternal
|
||||
) {
|
||||
reporter.reportOn(declaration.source, FirErrors.EXPECTED_EXTERNAL_DECLARATION, context)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,7 +637,7 @@ class DeclarationsChecker(
|
||||
}
|
||||
|
||||
checkExpectDeclarationHasNoExternalModifier(declaration)
|
||||
if (declaration is KtFunction) {
|
||||
if (declaration is KtFunction && languageVersionSettings.supportsFeature(LanguageFeature.MultiplatformRestrictions)) {
|
||||
declaration.modifierList?.getModifier(KtTokens.TAILREC_KEYWORD)?.let {
|
||||
trace.report(EXPECTED_TAILREC_FUNCTION.on(it))
|
||||
}
|
||||
@@ -645,8 +645,10 @@ class DeclarationsChecker(
|
||||
}
|
||||
|
||||
private fun checkExpectDeclarationHasNoExternalModifier(declaration: KtDeclaration) {
|
||||
declaration.modifierList?.getModifier(KtTokens.EXTERNAL_KEYWORD)?.let {
|
||||
trace.report(EXPECTED_EXTERNAL_DECLARATION.on(it))
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.MultiplatformRestrictions)) {
|
||||
declaration.modifierList?.getModifier(KtTokens.EXTERNAL_KEYWORD)?.let {
|
||||
trace.report(EXPECTED_EXTERNAL_DECLARATION.on(it))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// FIR_IDENTICAL
|
||||
// LANGUAGE: -MultiplatformRestrictions
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect external fun foo()
|
||||
|
||||
// MODULE: m1-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
actual external fun foo()
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// LANGUAGE: -MultiplatformRestrictions
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect <!NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo(p: Int): Int
|
||||
|
||||
// MODULE: m1-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
actual tailrec fun foo(p: Int): Int = foo(p)
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// LANGUAGE: -MultiplatformRestrictions
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect tailrec fun foo(p: Int): Int
|
||||
|
||||
// MODULE: m1-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
actual tailrec fun foo(p: Int): Int = foo(p)
|
||||
Generated
+12
@@ -23140,6 +23140,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/expectExternal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("expectExternal_oldLanguageVersion.kt")
|
||||
public void testExpectExternal_oldLanguageVersion() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/expectExternal_oldLanguageVersion.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("expectInterfaceApplicability.kt")
|
||||
public void testExpectInterfaceApplicability() throws Exception {
|
||||
@@ -23170,6 +23176,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/expectTailrec.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("expectTailrec_oldLanguageVersion.kt")
|
||||
public void testExpectTailrec_oldLanguageVersion() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/expectTailrec_oldLanguageVersion.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("headerFunInNonHeaderClass.kt")
|
||||
public void testHeaderFunInNonHeaderClass() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user