[FIR] Forbid @JvmInline with inline modifier
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com> #KT-1179
This commit is contained in:
committed by
Space Team
parent
3b5ad0681f
commit
888bf801e2
+6
@@ -34376,6 +34376,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/valueClasses/inefficientEqualsOverridingInMfvc.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inlineKeywordForMfvc.kt")
|
||||
public void testInlineKeywordForMfvc() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/valueClasses/inlineKeywordForMfvc.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmInlineApplicability.kt")
|
||||
public void testJvmInlineApplicability() throws Exception {
|
||||
|
||||
+6
@@ -34376,6 +34376,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/valueClasses/inefficientEqualsOverridingInMfvc.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inlineKeywordForMfvc.kt")
|
||||
public void testInlineKeywordForMfvc() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/valueClasses/inlineKeywordForMfvc.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmInlineApplicability.kt")
|
||||
public void testJvmInlineApplicability() throws Exception {
|
||||
|
||||
+6
@@ -34472,6 +34472,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/valueClasses/inefficientEqualsOverridingInMfvc.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inlineKeywordForMfvc.kt")
|
||||
public void testInlineKeywordForMfvc() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/valueClasses/inlineKeywordForMfvc.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmInlineApplicability.kt")
|
||||
public void testJvmInlineApplicability() throws Exception {
|
||||
|
||||
+2
-1
@@ -21,7 +21,8 @@ import org.jetbrains.kotlin.resolve.JVM_INLINE_ANNOTATION_CLASS_ID
|
||||
object FirJvmInlineApplicabilityChecker : FirRegularClassChecker() {
|
||||
override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
val annotation = declaration.getAnnotationByClassId(JVM_INLINE_ANNOTATION_CLASS_ID, context.session)
|
||||
if (annotation != null && !declaration.isInline) {
|
||||
if (annotation != null && !(declaration.isInline && declaration.getModifier(KtTokens.VALUE_KEYWORD) != null)) {
|
||||
// only report if value keyword does not exist, this includes the deprecated inline class syntax
|
||||
reporter.reportOn(annotation.source, FirJvmErrors.JVM_INLINE_WITHOUT_VALUE_CLASS, context)
|
||||
} else if (annotation == null && declaration.isInline && !declaration.isExpect) {
|
||||
// only report if value keyword exists, this ignores the deprecated inline class syntax
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// FIR_IDENTICAL
|
||||
// WITH_STDLIB
|
||||
// LANGUAGE: +ValueClasses
|
||||
|
||||
@file:Suppress("INLINE_CLASS_DEPRECATED")
|
||||
|
||||
inline class A1(val x: Int)
|
||||
|
||||
@JvmInline
|
||||
value class A2(val x: Int)
|
||||
|
||||
<!JVM_INLINE_WITHOUT_VALUE_CLASS!>@JvmInline<!>
|
||||
inline class A3(val x: Int)
|
||||
|
||||
<!VALUE_CLASS_WITHOUT_JVM_INLINE_ANNOTATION!>value<!> class A4(val x: Int)
|
||||
|
||||
|
||||
inline class B1(val x: Int, val y: Int)
|
||||
|
||||
@JvmInline
|
||||
value class B2(val x: Int, val y: Int)
|
||||
|
||||
<!JVM_INLINE_WITHOUT_VALUE_CLASS!>@JvmInline<!>
|
||||
inline class B3(val x: Int, val y: Int)
|
||||
|
||||
<!VALUE_CLASS_WITHOUT_JVM_INLINE_ANNOTATION!>value<!> class B4(val x: Int, val y: Int)
|
||||
|
||||
|
||||
inline class C1(val x: B2)
|
||||
|
||||
@JvmInline
|
||||
value class C2(val x: B2)
|
||||
|
||||
<!JVM_INLINE_WITHOUT_VALUE_CLASS!>@JvmInline<!>
|
||||
inline class C3(val x: B2)
|
||||
|
||||
<!VALUE_CLASS_WITHOUT_JVM_INLINE_ANNOTATION!>value<!> class C4(val x: B2)
|
||||
+1
-1
@@ -6,7 +6,7 @@ package kotlin.jvm
|
||||
|
||||
annotation class JvmInline
|
||||
|
||||
@JvmInline
|
||||
<!JVM_INLINE_WITHOUT_VALUE_CLASS!>@JvmInline<!>
|
||||
inline class IC(val a: Any)
|
||||
|
||||
@JvmInline
|
||||
|
||||
Generated
+6
@@ -34472,6 +34472,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/valueClasses/inefficientEqualsOverridingInMfvc.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inlineKeywordForMfvc.kt")
|
||||
public void testInlineKeywordForMfvc() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/valueClasses/inlineKeywordForMfvc.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmInlineApplicability.kt")
|
||||
public void testJvmInlineApplicability() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user