FIR: introduce inline classes checks

This commit is contained in:
eugenpolytechnic
2021-02-22 15:17:26 +03:00
committed by Mikhail Glukhikh
parent 9cc8f44390
commit f6e564ffa6
46 changed files with 923 additions and 238 deletions
@@ -2394,6 +2394,34 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
}
}
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/inlineClasses")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class InlineClasses extends AbstractLazyBodyIsNotTouchedTilContractsPhaseTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInInlineClasses() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/inlineClasses"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@TestMetadata("inlineClassConstructor.kt")
public void testInlineClassConstructor() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inlineClasses/inlineClassConstructor.kt");
}
@TestMetadata("inlineClassDeclaration.kt")
public void testInlineClassDeclaration() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inlineClasses/inlineClassDeclaration.kt");
}
@TestMetadata("inlineClassMembers.kt")
public void testInlineClassMembers() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inlineClasses/inlineClassMembers.kt");
}
}
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/innerClasses")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -18,4 +18,4 @@ class SomeClass : SomeInterface {
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var fau: Double
}
inline class InlineClass
<!ABSENCE_OF_PRIMARY_CONSTRUCTOR_FOR_INLINE_CLASS!>inline<!> class InlineClass
@@ -0,0 +1,146 @@
FILE: inlineClassConstructor.kt
public final class WithoutConstructor : R|kotlin/Any| {
public constructor(): R|WithoutConstructor| {
super<R|kotlin/Any|>()
}
}
public final inline class WithoutParameter : R|kotlin/Any| {
public constructor(): R|WithoutParameter| {
super<R|kotlin/Any|>()
}
}
public final inline class WithTwoParameters : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|, y: R|kotlin/String|): R|WithTwoParameters| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
public final val y: R|kotlin/String| = R|<local>/y|
public get(): R|kotlin/String|
}
public final inline class Ok : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|Ok| {
super<R|kotlin/Any|>()
}
private final val x: R|kotlin/Int| = R|<local>/x|
private get(): R|kotlin/Int|
}
public final inline class OpenParameter : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|OpenParameter| {
super<R|kotlin/Any|>()
}
public open val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
}
public final inline class VarargParameter : R|kotlin/Any| {
public constructor(vararg x: R|kotlin/IntArray|): R|VarargParameter| {
super<R|kotlin/Any|>()
}
}
public final inline class VarParameter : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|VarParameter| {
super<R|kotlin/Any|>()
}
public final var x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
public set(value: R|kotlin/Int|): R|kotlin/Unit|
}
public final inline class SimpleParameter : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|SimpleParameter| {
super<R|kotlin/Any|>()
}
}
public final inline class UnitParameter : R|kotlin/Any| {
public constructor(x: R|kotlin/Unit|): R|UnitParameter| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Unit| = R|<local>/x|
public get(): R|kotlin/Unit|
}
public final inline class NothingParameter : R|kotlin/Any| {
public constructor(x: R|kotlin/Nothing|): R|NothingParameter| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Nothing| = R|<local>/x|
public get(): R|kotlin/Nothing|
}
public final inline class TypeParameterType<T> : R|kotlin/Any| {
public constructor<T>(x: R|T|): R|TypeParameterType<T>| {
super<R|kotlin/Any|>()
}
public final val x: R|T| = R|<local>/x|
public get(): R|T|
}
public final inline class ArrayOfTypeParameters<T> : R|kotlin/Any| {
public constructor<T>(x: R|kotlin/Array<T>|): R|ArrayOfTypeParameters<T>| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Array<T>| = R|<local>/x|
public get(): R|kotlin/Array<T>|
}
public final inline class ListOfTypeParameters<T> : R|kotlin/Any| {
public constructor<T>(x: R|kotlin/collections/List<T>|): R|ListOfTypeParameters<T>| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/collections/List<T>| = R|<local>/x|
public get(): R|kotlin/collections/List<T>|
}
public final inline class StarProjection<T> : R|kotlin/Any| {
public constructor<T>(x: R|kotlin/Array<*>|): R|StarProjection<T>| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Array<*>| = R|<local>/x|
public get(): R|kotlin/Array<*>|
}
public final inline class SimpleRecursive : R|kotlin/Any| {
public constructor(x: R|SimpleRecursive|): R|SimpleRecursive| {
super<R|kotlin/Any|>()
}
public final val x: R|SimpleRecursive| = R|<local>/x|
public get(): R|SimpleRecursive|
}
public final inline class DoubleRecursive1 : R|kotlin/Any| {
public constructor(x: R|DoubleRecursive2|): R|DoubleRecursive1| {
super<R|kotlin/Any|>()
}
public final val x: R|DoubleRecursive2| = R|<local>/x|
public get(): R|DoubleRecursive2|
}
public final inline class DoubleRecursive2 : R|kotlin/Any| {
public constructor(x: R|DoubleRecursive1|): R|DoubleRecursive2| {
super<R|kotlin/Any|>()
}
public final val x: R|DoubleRecursive1| = R|<local>/x|
public get(): R|DoubleRecursive1|
}
@@ -0,0 +1,21 @@
<!ABSENCE_OF_PRIMARY_CONSTRUCTOR_FOR_INLINE_CLASS!>value<!> class WithoutConstructor {}
inline class WithoutParameter<!INLINE_CLASS_CONSTRUCTOR_WRONG_PARAMETERS_SIZE!>()<!> {}
inline class WithTwoParameters<!INLINE_CLASS_CONSTRUCTOR_WRONG_PARAMETERS_SIZE!>(val x: Int, val y: String)<!> {}
inline class Ok(private val x: Int) {}
inline class OpenParameter(<!INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER!><!NON_FINAL_MEMBER_IN_FINAL_CLASS!>open<!> val x: Int<!>) {}
inline class VarargParameter(<!INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER!>vararg x: Int<!>) {}
inline class VarParameter(<!INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER!>var x: Int<!>) {}
inline class SimpleParameter(<!INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER!>x: Int<!>) {}
inline class UnitParameter(val x: <!INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE!>Unit<!>)
inline class NothingParameter(val x: <!INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE!>Nothing<!>)
inline class TypeParameterType<T>(val x: <!INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE!>T<!>)
inline class ArrayOfTypeParameters<T>(val x: <!INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE!>Array<T><!>)
inline class ListOfTypeParameters<T>(val x: List<T>)
inline class StarProjection<T>(val x: Array<*>)
inline class SimpleRecursive(val x: <!INLINE_CLASS_CANNOT_BE_RECURSIVE!>SimpleRecursive<!>)
inline class DoubleRecursive1(val x: <!INLINE_CLASS_CANNOT_BE_RECURSIVE!>DoubleRecursive2<!>)
inline class DoubleRecursive2(val x: <!INLINE_CLASS_CANNOT_BE_RECURSIVE!>DoubleRecursive1<!>)
@@ -0,0 +1,111 @@
FILE: inlineClassDeclaration.kt
public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public final inline class B : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|A.B| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
}
public final fun foo(): R|kotlin/Unit| {
local final inline class C : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|A.C| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
}
}
public final inner class D : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|A.D| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
}
}
public open inline class NotFinalClass1 : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|NotFinalClass1| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
}
public abstract inline class NotFinalClass2 : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|NotFinalClass2| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
}
public sealed inline class NotFinalClass3 : R|kotlin/Any| {
protected constructor(x: R|kotlin/Int|): R|NotFinalClass3| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
}
public final class CloneableClass1 : R|kotlin/Cloneable| {
public constructor(x: R|kotlin/Int|): R|CloneableClass1| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
}
public final inline class CloneableClass2 : R|java/lang/Cloneable| {
public constructor(x: R|kotlin/Int|): R|CloneableClass2| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
}
public open class Test : R|kotlin/Any| {
public constructor(): R|Test| {
super<R|kotlin/Any|>()
}
}
public final inline class ExtendTest : R|Test| {
public constructor(x: R|kotlin/Int|): R|ExtendTest| {
super<R|Test|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
}
public final inline class ImplementByDelegation : R|kotlin/Comparable<kotlin/Int>| {
public constructor(x: R|kotlin/Int|): R|ImplementByDelegation| {
super<R|kotlin/Any|>()
}
local final field <$$delegate_0>: R|kotlin/Comparable<kotlin/Int>| = R|<local>/x|
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
}
@@ -0,0 +1,19 @@
class A {
<!INLINE_CLASS_NOT_TOP_LEVEL!>inline<!> class B(val x: Int)
fun foo() {
<!INLINE_CLASS_NOT_TOP_LEVEL!>inline<!> class C(val x: Int)
}
inner <!INLINE_CLASS_NOT_TOP_LEVEL!>value<!> class D(val x: Int)
}
<!INLINE_CLASS_NOT_FINAL!>open<!> inline class NotFinalClass1(val x: Int)
<!INLINE_CLASS_NOT_FINAL!>abstract<!> inline class NotFinalClass2(val x: Int)
<!INLINE_CLASS_NOT_FINAL!>sealed<!> inline class NotFinalClass3(val x: Int)
<!VALUE_CLASS_CANNOT_BE_CLONEABLE!>value<!> class CloneableClass1(val x: Int): Cloneable
<!VALUE_CLASS_CANNOT_BE_CLONEABLE!>inline<!> class CloneableClass2(val x: Int): java.lang.Cloneable
open class Test
inline class ExtendTest(val x: Int): <!INLINE_CLASS_CANNOT_EXTEND_CLASSES!>Test<!>
inline class ImplementByDelegation(val x: Int) : <!INLINE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION!>Comparable<Int><!> by x
@@ -0,0 +1,100 @@
FILE: inlineClassMembers.kt
public final class BackingFields : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|BackingFields| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
public final val y: R|kotlin/Int| = Int(0)
public get(): R|kotlin/Int|
public final var z: R|kotlin/String|
public get(): R|kotlin/String| {
^ String()
}
public set(value: R|kotlin/String|): R|kotlin/Unit| {
}
}
public final class Val : R|kotlin/Any| {
public constructor(): R|Val| {
super<R|kotlin/Any|>()
}
public final operator fun getValue(thisRef: R|kotlin/Any?|, kProp: R|kotlin/Any?|): R|kotlin/Int| {
^getValue Int(1)
}
}
public final inline class DelegatedProp : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|DelegatedProp| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
public final val testVal: R|kotlin/Int|by R|/Val.Val|()
public get(): R|kotlin/Int| {
^ this@R|/DelegatedProp|.D|/DelegatedProp.testVal|.R|/Val.getValue|(this@R|/DelegatedProp|, ::R|/DelegatedProp.testVal|)
}
}
public final inline class ReversedMembers : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|ReversedMembers| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
public final fun box(): R|kotlin/Unit| {
}
public final fun unbox(): R|kotlin/Unit| {
}
public final override operator fun equals(other: R|kotlin/Any?|): R|kotlin/Boolean| {
^equals Boolean(true)
}
public final override fun hashCode(): R|kotlin/Int| {
^hashCode Int(1)
}
}
public final inline class SecondaryConstructors : R|kotlin/Any| {
public constructor(x: R|kotlin/Int|): R|SecondaryConstructors| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
public constructor(y: R|kotlin/String|): R|SecondaryConstructors| {
this<R|SecondaryConstructors|>(Int(5))
}
public constructor(x: R|kotlin/Int|, y: R|kotlin/String|): R|SecondaryConstructors| {
this<R|SecondaryConstructors|>(R|<local>/x|)
}
}
public final class WithInner : R|kotlin/Any| {
public constructor(x: R|kotlin/String|): R|WithInner| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/String| = R|<local>/x|
public get(): R|kotlin/String|
public final inner class Inner : R|kotlin/Any| {
public constructor(): R|WithInner.Inner| {
super<R|kotlin/Any|>()
}
}
}
@@ -0,0 +1,32 @@
value class BackingFields(val x: Int) {
<!PROPERTY_WITH_BACKING_FIELD_INSIDE_INLINE_CLASS!>val y<!> = 0
var z: String
get() = ""
set(value) {}
}
class Val {
operator fun getValue(thisRef: Any?, kProp: Any?) = 1
}
inline class DelegatedProp(val x: Int) {
val testVal by <!DELEGATED_PROPERTY_INSIDE_INLINE_CLASS!>Val()<!>
}
inline class ReversedMembers(val x: Int) {
<!RESERVED_MEMBER_INSIDE_INLINE_CLASS{LT}!>fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS{PSI}!>box<!>() {}<!>
<!RESERVED_MEMBER_INSIDE_INLINE_CLASS{LT}!>fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS{PSI}!>unbox<!>() {}<!>
<!RESERVED_MEMBER_INSIDE_INLINE_CLASS{LT}!>override fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS{PSI}!>equals<!>(other: Any?) = true<!>
<!RESERVED_MEMBER_INSIDE_INLINE_CLASS{LT}!>override fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS{PSI}!>hashCode<!>() = 1<!>
}
inline class SecondaryConstructors(val x: Int) {
constructor(y: String) : this(5)
constructor(x: Int, y: String) : this(x) <!SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_INLINE_CLASS!>{
}<!>
}
value class WithInner(val x: String) {
<!INNER_CLASS_INSIDE_INLINE_CLASS!>inner<!> class Inner
}
@@ -2724,6 +2724,34 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
}
}
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/inlineClasses")
@TestDataPath("$PROJECT_ROOT")
public class InlineClasses {
@Test
public void testAllFilesPresentInInlineClasses() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/inlineClasses"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@Test
@TestMetadata("inlineClassConstructor.kt")
public void testInlineClassConstructor() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inlineClasses/inlineClassConstructor.kt");
}
@Test
@TestMetadata("inlineClassDeclaration.kt")
public void testInlineClassDeclaration() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inlineClasses/inlineClassDeclaration.kt");
}
@Test
@TestMetadata("inlineClassMembers.kt")
public void testInlineClassMembers() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inlineClasses/inlineClassMembers.kt");
}
}
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/innerClasses")
@TestDataPath("$PROJECT_ROOT")
@@ -2752,6 +2752,35 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
}
}
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/inlineClasses")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class InlineClasses {
@Test
public void testAllFilesPresentInInlineClasses() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/inlineClasses"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@Test
@TestMetadata("inlineClassConstructor.kt")
public void testInlineClassConstructor() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inlineClasses/inlineClassConstructor.kt");
}
@Test
@TestMetadata("inlineClassDeclaration.kt")
public void testInlineClassDeclaration() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inlineClasses/inlineClassDeclaration.kt");
}
@Test
@TestMetadata("inlineClassMembers.kt")
public void testInlineClassMembers() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inlineClasses/inlineClassMembers.kt");
}
}
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/innerClasses")
@TestDataPath("$PROJECT_ROOT")
@@ -42,6 +42,8 @@ enum class PositioningStrategy(private val strategy: String? = null) {
IF_EXPRESSION,
VARIANCE_MODIFIER,
LATEINIT_MODIFIER,
INLINE_OR_VALUE_MODIFIER,
INNER_MODIFIER,
SELECTOR_BY_QUALIFIED,
REFERENCE_BY_QUALIFIED,
PRIVATE_MODIFIER,
@@ -154,6 +154,28 @@ object DIAGNOSTICS_LIST : DiagnosticList() {
val REDUNDANT_OPEN_IN_INTERFACE by warning<FirSourceElement, KtModifierListOwner>(PositioningStrategy.OPEN_MODIFIER)
}
val INLINE_CLASSES by object : DiagnosticGroup("Inline classes") {
val INLINE_CLASS_NOT_TOP_LEVEL by error<FirSourceElement, KtDeclaration>(PositioningStrategy.INLINE_OR_VALUE_MODIFIER)
val INLINE_CLASS_NOT_FINAL by error<FirSourceElement, KtDeclaration>(PositioningStrategy.MODALITY_MODIFIER)
val ABSENCE_OF_PRIMARY_CONSTRUCTOR_FOR_INLINE_CLASS by error<FirSourceElement, KtDeclaration>(PositioningStrategy.INLINE_OR_VALUE_MODIFIER)
val INLINE_CLASS_CONSTRUCTOR_WRONG_PARAMETERS_SIZE by error<FirSourceElement, KtElement>()
val INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER by error<FirSourceElement, KtParameter>()
val PROPERTY_WITH_BACKING_FIELD_INSIDE_INLINE_CLASS by error<FirSourceElement, KtProperty>(PositioningStrategy.DECLARATION_SIGNATURE)
val DELEGATED_PROPERTY_INSIDE_INLINE_CLASS by error<FirSourceElement, PsiElement>()
val INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE by error<FirSourceElement, KtTypeReference> {
parameter<ConeKotlinType>("type")
}
val INLINE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION by error<FirSourceElement, PsiElement>()
val INLINE_CLASS_CANNOT_EXTEND_CLASSES by error<FirSourceElement, KtTypeReference>()
val INLINE_CLASS_CANNOT_BE_RECURSIVE by error<FirSourceElement, KtTypeReference>()
val RESERVED_MEMBER_INSIDE_INLINE_CLASS by error<FirSourceElement, KtFunction>(PositioningStrategy.DECLARATION_NAME) {
parameter<String>("fun name")
}
val SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_INLINE_CLASS by error<FirSourceElement, PsiElement>()
val INNER_CLASS_INSIDE_INLINE_CLASS by error<FirSourceElement, KtDeclaration>(PositioningStrategy.INNER_MODIFIER)
val VALUE_CLASS_CANNOT_BE_CLONEABLE by error<FirSourceElement, KtDeclaration>(PositioningStrategy.INLINE_OR_VALUE_MODIFIER)
}
val APPLICABILITY by object : DiagnosticGroup("Applicability") {
val NONE_APPLICABLE by error<FirSourceElement, PsiElement>(PositioningStrategy.REFERENCE_BY_QUALIFIED) {
parameter<Collection<AbstractFirBasedSymbol<*>>>("candidates")
@@ -141,6 +141,23 @@ object FirErrors {
val INCOMPATIBLE_MODIFIERS by error2<FirSourceElement, PsiElement, KtModifierKeywordToken, KtModifierKeywordToken>()
val REDUNDANT_OPEN_IN_INTERFACE by warning0<FirSourceElement, KtModifierListOwner>(SourceElementPositioningStrategies.OPEN_MODIFIER)
// Inline classes
val INLINE_CLASS_NOT_TOP_LEVEL by error0<FirSourceElement, KtDeclaration>(SourceElementPositioningStrategies.INLINE_OR_VALUE_MODIFIER)
val INLINE_CLASS_NOT_FINAL by error0<FirSourceElement, KtDeclaration>(SourceElementPositioningStrategies.MODALITY_MODIFIER)
val ABSENCE_OF_PRIMARY_CONSTRUCTOR_FOR_INLINE_CLASS by error0<FirSourceElement, KtDeclaration>(SourceElementPositioningStrategies.INLINE_OR_VALUE_MODIFIER)
val INLINE_CLASS_CONSTRUCTOR_WRONG_PARAMETERS_SIZE by error0<FirSourceElement, KtElement>()
val INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER by error0<FirSourceElement, KtParameter>()
val PROPERTY_WITH_BACKING_FIELD_INSIDE_INLINE_CLASS by error0<FirSourceElement, KtProperty>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE)
val DELEGATED_PROPERTY_INSIDE_INLINE_CLASS by error0<FirSourceElement, PsiElement>()
val INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE by error1<FirSourceElement, KtTypeReference, ConeKotlinType>()
val INLINE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION by error0<FirSourceElement, PsiElement>()
val INLINE_CLASS_CANNOT_EXTEND_CLASSES by error0<FirSourceElement, KtTypeReference>()
val INLINE_CLASS_CANNOT_BE_RECURSIVE by error0<FirSourceElement, KtTypeReference>()
val RESERVED_MEMBER_INSIDE_INLINE_CLASS by error1<FirSourceElement, KtFunction, String>(SourceElementPositioningStrategies.DECLARATION_NAME)
val SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_INLINE_CLASS by error0<FirSourceElement, PsiElement>()
val INNER_CLASS_INSIDE_INLINE_CLASS by error0<FirSourceElement, KtDeclaration>(SourceElementPositioningStrategies.INNER_MODIFIER)
val VALUE_CLASS_CANNOT_BE_CLONEABLE by error0<FirSourceElement, KtDeclaration>(SourceElementPositioningStrategies.INLINE_OR_VALUE_MODIFIER)
// Applicability
val NONE_APPLICABLE by error1<FirSourceElement, PsiElement, Collection<AbstractFirBasedSymbol<*>>>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
val INAPPLICABLE_CANDIDATE by error1<FirSourceElement, PsiElement, AbstractFirBasedSymbol<*>>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.fir.FirFakeSourceElementKind
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.modality
@@ -171,3 +172,10 @@ private val FirProperty.hasAccessorImplementation: Boolean
(setter !is FirDefaultPropertyAccessor && setter?.hasBody == true)
internal val FirClass<*>.canHaveOpenMembers: Boolean get() = modality() != Modality.FINAL || classKind == ClassKind.ENUM_CLASS
internal fun FirRegularClass.isInlineOrValueClass(): Boolean {
if (this.classKind != ClassKind.CLASS) return false
val modifierList = with(FirModifierList) { source.getModifierList() }
return isInline || modifierList?.modifiers?.any { it.token == KtTokens.VALUE_KEYWORD } == true
}
@@ -0,0 +1,198 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.analysis.checkers.declaration
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClass
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.resolve.calls.isPotentiallyArray
import org.jetbrains.kotlin.fir.resolve.defaultType
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.types.AbstractTypeChecker
object FirInlineClassDeclarationChecker : FirRegularClassChecker() {
private val reservedFunctionNames = setOf("box", "unbox", "equals", "hashCode")
private val kotlinCloneableType = ClassId.fromString("kotlin/Cloneable").constructClassLikeType(emptyArray(), false)
private val javaCloneableType = ClassId.fromString("java/lang/Cloneable").constructClassLikeType(emptyArray(), false)
override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) {
if (!declaration.isInlineOrValueClass()) {
return
}
if (context.containingDeclarations.size > 1) {
reporter.reportOn(declaration.source, FirErrors.INLINE_CLASS_NOT_TOP_LEVEL, context)
}
if (declaration.modality != Modality.FINAL) {
reporter.reportOn(declaration.source, FirErrors.INLINE_CLASS_NOT_FINAL, context)
}
for (supertypeEntry in declaration.superTypeRefs) {
if (supertypeEntry.toRegularClass(context.session)?.isInterface != true) {
reporter.reportOn(supertypeEntry.source, FirErrors.INLINE_CLASS_CANNOT_EXTEND_CLASSES, context)
}
}
if (declaration.isSubtypeOfCloneable(context)) {
reporter.reportOn(declaration.source, FirErrors.VALUE_CLASS_CANNOT_BE_CLONEABLE, context)
}
var primaryConstructor: FirConstructor? = null
var primaryConstructorParameter: FirValueParameter? = null
var primaryConstructorProperty: FirProperty? = null
for (innerDeclaration in declaration.declarations) {
when (innerDeclaration) {
is FirConstructor -> {
when {
innerDeclaration.isPrimary -> {
primaryConstructor = innerDeclaration
primaryConstructorParameter = innerDeclaration.valueParameters.singleOrNull()
}
innerDeclaration.body != null -> {
val bodySource = innerDeclaration.body!!.source
reporter.reportOn(bodySource, FirErrors.SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_INLINE_CLASS, context)
}
}
}
is FirRegularClass -> {
if (innerDeclaration.isInner) {
reporter.reportOn(innerDeclaration.source, FirErrors.INNER_CLASS_INSIDE_INLINE_CLASS, context)
}
}
is FirSimpleFunction -> {
val functionName = innerDeclaration.name.asString()
if (functionName in reservedFunctionNames) {
reporter.reportOn(innerDeclaration.source, FirErrors.RESERVED_MEMBER_INSIDE_INLINE_CLASS, functionName, context)
}
}
is FirField -> {
if (innerDeclaration.isSynthetic) {
val delegatedTypeRefSource = (innerDeclaration.returnTypeRef as FirResolvedTypeRef).delegatedTypeRef?.source
reporter.reportOn(delegatedTypeRefSource, FirErrors.INLINE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION, context)
}
}
is FirProperty -> {
if (innerDeclaration.isRelatedToParameter(primaryConstructorParameter)) {
primaryConstructorProperty = innerDeclaration
} else {
when {
innerDeclaration.delegate != null ->
reporter.reportOn(
innerDeclaration.delegate!!.source,
FirErrors.DELEGATED_PROPERTY_INSIDE_INLINE_CLASS,
context
)
innerDeclaration.hasBackingField &&
innerDeclaration.source?.kind !is FirFakeSourceElementKind ->
reporter.reportOn(
innerDeclaration.source,
FirErrors.PROPERTY_WITH_BACKING_FIELD_INSIDE_INLINE_CLASS,
context
)
}
}
}
}
}
if (primaryConstructor?.source?.kind !is FirRealSourceElementKind) {
reporter.reportOn(declaration.source, FirErrors.ABSENCE_OF_PRIMARY_CONSTRUCTOR_FOR_INLINE_CLASS, context)
return
}
if (primaryConstructorParameter == null) {
reporter.reportOn(primaryConstructor.source, FirErrors.INLINE_CLASS_CONSTRUCTOR_WRONG_PARAMETERS_SIZE, context)
return
}
when {
primaryConstructorParameter.isNotFinalReadOnly(primaryConstructorProperty) ->
reporter.reportOn(
primaryConstructorParameter.source,
FirErrors.INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER,
context
)
primaryConstructorParameter.returnTypeRef.isInapplicableParameterType() ->
reporter.reportOn(
primaryConstructorParameter.returnTypeRef.source,
FirErrors.INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE,
primaryConstructorParameter.returnTypeRef.coneType,
context
)
primaryConstructorParameter.returnTypeRef.coneType.isRecursiveInlineClassType(context.session) ->
reporter.reportOn(
primaryConstructorParameter.returnTypeRef.source,
FirErrors.INLINE_CLASS_CANNOT_BE_RECURSIVE,
context
)
}
}
private fun FirProperty.isRelatedToParameter(parameter: FirValueParameter?) =
name == parameter?.name && source?.kind is FirFakeSourceElementKind
private fun FirValueParameter.isNotFinalReadOnly(primaryConstructorProperty: FirProperty?): Boolean {
if (primaryConstructorProperty == null) return true
val modifierList = with(FirModifierList) { source.getModifierList() }
val isOpen = modifierList?.modifiers?.any { it.token == KtTokens.OPEN_KEYWORD } == true
return isVararg || !primaryConstructorProperty.isVal || isOpen
}
private fun FirTypeRef.isInapplicableParameterType() =
isUnit || isNothing || coneType is ConeTypeParameterType || coneType.isGenericArrayOfTypeParameter()
private fun ConeKotlinType.isGenericArrayOfTypeParameter(): Boolean {
if (this.typeArguments.firstOrNull() is ConeStarProjection || !isPotentiallyArray())
return false
val arrayElementType = arrayElementType()?.type ?: return false
return arrayElementType is ConeTypeParameterType ||
arrayElementType.isGenericArrayOfTypeParameter()
}
private fun ConeKotlinType.isRecursiveInlineClassType(session: FirSession) =
isRecursiveInlineClassType(hashSetOf(), session)
private fun ConeKotlinType.isRecursiveInlineClassType(visited: HashSet<ConeKotlinType>, session: FirSession): Boolean {
if (!visited.add(this)) return true
val asRegularClass = this.toRegularClass(session) ?: return false
return asRegularClass.isInlineOrValueClass() &&
asRegularClass.primaryConstructor
?.takeIf { it.source?.kind is FirRealSourceElementKind }
?.valueParameters
?.firstOrNull()
?.returnTypeRef
?.coneType
?.isRecursiveInlineClassType(visited, session) == true
}
private fun FirRegularClass.isSubtypeOfCloneable(context: CheckerContext): Boolean {
val coneType = this.defaultType()
val typeContext = context.session.typeContext
return AbstractTypeChecker.isSubtypeOf(typeContext, coneType, kotlinCloneableType) ||
AbstractTypeChecker.isSubtypeOf(typeContext, coneType, javaCloneableType)
}
}
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMB
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.TO_STRING
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.VISIBILITY
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.WHEN_MISSING_CASES
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSENCE_OF_PRIMARY_CONSTRUCTOR_FOR_INLINE_CLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_DELEGATED_PROPERTY
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_FUNCTION_WITH_BODY
@@ -53,6 +54,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONFLICTING_PROJE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONSTRUCTOR_IN_INTERFACE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONSTRUCTOR_IN_OBJECT
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CYCLIC_CONSTRUCTOR_DELEGATION_CALL
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DELEGATED_PROPERTY_INSIDE_INLINE_CLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DELEGATED_PROPERTY_IN_INTERFACE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DELEGATION_IN_INTERFACE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR
@@ -89,6 +91,15 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INAPPLICABLE_LATE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INCOMPATIBLE_MODIFIERS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INFERENCE_ERROR
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INLINE_CLASS_CANNOT_BE_RECURSIVE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INLINE_CLASS_CANNOT_EXTEND_CLASSES
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INLINE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INLINE_CLASS_CONSTRUCTOR_WRONG_PARAMETERS_SIZE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INLINE_CLASS_NOT_FINAL
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INLINE_CLASS_NOT_TOP_LEVEL
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INNER_CLASS_INSIDE_INLINE_CLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INSTANCE_ACCESS_BEFORE_SUPER_CALL
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INTERFACE_WITH_SUPERCLASS
@@ -132,6 +143,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PROJECTION_ON_NON
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PROPERTY_INITIALIZER_IN_INTERFACE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PROPERTY_INITIALIZER_NO_BACKING_FIELD
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PROPERTY_TYPE_MISMATCH_ON_OVERRIDE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PROPERTY_WITH_BACKING_FIELD_INSIDE_INLINE_CLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PROPERTY_WITH_NO_TYPE_NO_INITIALIZER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.QUALIFIED_SUPERTYPE_EXTENDED_BY_OTHER_SUPERTYPE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RECURSION_IN_IMPLICIT_TYPES
@@ -148,11 +160,13 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REDUNDANT_SINGLE_
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REDUNDANT_VISIBILITY_MODIFIER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REIFIED_TYPE_IN_CATCH_CLAUSE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REPEATED_MODIFIER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RESERVED_MEMBER_INSIDE_INLINE_CLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RETURN_NOT_ALLOWED
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RETURN_TYPE_MISMATCH_ON_OVERRIDE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SEALED_CLASS_CONSTRUCTOR_CALL
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SEALED_SUPERTYPE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SEALED_SUPERTYPE_IN_LOCAL_CLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_INLINE_CLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SUPERCLASS_NOT_ACCESSIBLE_FROM_INTERFACE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SUPERTYPE_INITIALIZED_IN_INTERFACE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR
@@ -178,6 +192,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.UPPER_BOUND_VIOLA
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.USELESS_VARARG_ON_PARAMETER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VAL_REASSIGNMENT
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VAL_WITH_SETTER
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VALUE_CLASS_CANNOT_BE_CLONEABLE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VARARG_OUTSIDE_PARENTHESES
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VARIABLE_EXPECTED
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VARIABLE_INITIALIZER_IS_REDUNDANT
@@ -369,6 +384,23 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension {
map.put(CLASS_LITERAL_LHS_NOT_A_CLASS, "Only classes are allowed on the left hand side of a class literal")
map.put(NULLABLE_TYPE_IN_CLASS_LITERAL_LHS, "Type in a class literal must not be nullable")
// Inline and value classes
map.put(INLINE_CLASS_NOT_TOP_LEVEL, "Inline classes cannot be local or inner")
map.put(INLINE_CLASS_NOT_FINAL, "Inline classes can be only final")
map.put(ABSENCE_OF_PRIMARY_CONSTRUCTOR_FOR_INLINE_CLASS, "Primary constructor is required for inline class")
map.put(INLINE_CLASS_CONSTRUCTOR_WRONG_PARAMETERS_SIZE, "Inline class must have exactly one primary constructor parameter")
map.put(INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER, "Value class primary constructor must have only final read-only (val) property parameter")
map.put(PROPERTY_WITH_BACKING_FIELD_INSIDE_INLINE_CLASS, "Inline class cannot have properties with backing fields")
map.put(DELEGATED_PROPERTY_INSIDE_INLINE_CLASS, "Inline class cannot have delegated properties")
map.put(INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE, "Inline class cannot have value parameter of type ''{0}''", TO_STRING)
map.put(INLINE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION, "Inline class cannot implement an interface by delegation")
map.put(INLINE_CLASS_CANNOT_EXTEND_CLASSES, "Inline class cannot extend classes")
map.put(INLINE_CLASS_CANNOT_BE_RECURSIVE, "Inline class cannot be recursive")
map.put(RESERVED_MEMBER_INSIDE_INLINE_CLASS, "Member with the name ''{0}'' is reserved for future releases", TO_STRING)
map.put(SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_INLINE_CLASS, "Secondary constructors with bodies are reserved for for future releases")
map.put(INNER_CLASS_INSIDE_INLINE_CLASS, "Inline class cannot have inner classes")
map.put(VALUE_CLASS_CANNOT_BE_CLONEABLE, "Value class cannot be Cloneable")
// Overrides
map.put(NOTHING_TO_OVERRIDE, "''{0}'' overrides nothing", DECLARATION_NAME)
map.put(OVERRIDING_FINAL_MEMBER, "''{0}'' in ''{1}'' is final and cannot be overridden", NAME, TO_STRING)
@@ -295,6 +295,12 @@ object LightTreePositioningStrategies {
val CONST_MODIFIER: LightTreePositioningStrategy =
ModifierSetBasedLightTreePositioningStrategy(TokenSet.create(KtTokens.CONST_KEYWORD))
val INLINE_OR_VALUE_MODIFIER: LightTreePositioningStrategy =
ModifierSetBasedLightTreePositioningStrategy(TokenSet.create(KtTokens.INLINE_KEYWORD, KtTokens.VALUE_KEYWORD))
val INNER_MODIFIER: LightTreePositioningStrategy =
ModifierSetBasedLightTreePositioningStrategy(TokenSet.create(KtTokens.INNER_KEYWORD))
val OPERATOR: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
override fun mark(
node: LighterASTNode,
@@ -93,6 +93,16 @@ object SourceElementPositioningStrategies {
PositioningStrategies.CONST_MODIFIER
)
val INLINE_OR_VALUE_MODIFIER = SourceElementPositioningStrategy(
LightTreePositioningStrategies.INLINE_OR_VALUE_MODIFIER,
PositioningStrategies.INLINE_OR_VALUE_MODIFIER
)
val INNER_MODIFIER = SourceElementPositioningStrategy(
LightTreePositioningStrategies.INNER_MODIFIER,
PositioningStrategies.INNER_MODIFIER
)
val OPERATOR = SourceElementPositioningStrategy(
LightTreePositioningStrategies.OPERATOR,
PositioningStrategies.OPERATOR
@@ -62,6 +62,7 @@ object CommonDeclarationCheckers : DeclarationCheckers() {
FirMemberFunctionsChecker,
FirMemberPropertiesChecker,
FirNestedClassChecker,
FirInlineClassDeclarationChecker,
)
override val constructorCheckers: Set<FirConstructorChecker> = setOf(
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.cfg.UnreachableCode
import org.jetbrains.kotlin.diagnostics.Errors.ACTUAL_WITHOUT_EXPECT
import org.jetbrains.kotlin.diagnostics.Errors.NO_ACTUAL_FOR_EXPECT
import org.jetbrains.kotlin.diagnostics.PositioningStrategies.INNER_MODIFIER
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.lexer.KtTokens.MODALITY_MODIFIERS
@@ -440,6 +441,14 @@ object PositioningStrategies {
@JvmField
val MODALITY_MODIFIER: PositioningStrategy<KtModifierListOwner> = ModifierSetBasedPositioningStrategy(MODALITY_MODIFIERS)
@JvmField
val INLINE_OR_VALUE_MODIFIER: PositioningStrategy<KtModifierListOwner> =
ModifierSetBasedPositioningStrategy(TokenSet.create(KtTokens.INLINE_KEYWORD, KtTokens.VALUE_KEYWORD))
@JvmField
val INNER_MODIFIER: PositioningStrategy<KtModifierListOwner> =
ModifierSetBasedPositioningStrategy(TokenSet.create(KtTokens.INNER_KEYWORD))
@JvmField
val VARIANCE_IN_PROJECTION: PositioningStrategy<KtTypeProjection> = object : PositioningStrategy<KtTypeProjection>() {
override fun mark(element: KtTypeProjection): List<TextRange> {
@@ -7,4 +7,4 @@ inline annotation class InlineAnn
inline object InlineObject
inline enum class InlineEnum
inline class NotVal(x: Int)
inline class NotVal(<!INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER!>x: Int<!>)
@@ -20,9 +20,9 @@ object VarObject {
}
inline class Z(val data: Int) {
val testVal by Val()
var testVar by Var()
val testVal by <!DELEGATED_PROPERTY_INSIDE_INLINE_CLASS!>Val()<!>
var testVar by <!DELEGATED_PROPERTY_INSIDE_INLINE_CLASS!>Var()<!>
val testValBySingleton by ValObject
var testVarBySingleton by VarObject
}
val testValBySingleton by <!DELEGATED_PROPERTY_INSIDE_INLINE_CLASS!>ValObject<!>
var testVarBySingleton by <!DELEGATED_PROPERTY_INSIDE_INLINE_CLASS!>VarObject<!>
}
@@ -1,13 +0,0 @@
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses
abstract class AbstractBaseClass
open class OpenBaseClass
interface BaseInterface
inline class TestExtendsAbstractClass(val x: Int) : AbstractBaseClass()
inline class TestExtendsOpenClass(val x: Int) : OpenBaseClass()
inline class TestImplementsInterface(val x: Int) : BaseInterface
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses
abstract class AbstractBaseClass
@@ -4,6 +4,6 @@ interface IFoo
object FooImpl : IFoo
inline class Test1(val x: Any) : IFoo by FooImpl
inline class Test1(val x: Any) : <!INLINE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION!>IFoo<!> by FooImpl
inline class Test2(val x: IFoo) : IFoo by x
inline class Test2(val x: IFoo) : <!INLINE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION!>IFoo<!> by x
@@ -3,38 +3,38 @@
inline class A0(val x: Int)
inline class A1
inline class A2()
inline class A3(x: Int)
inline class A4(var x: Int)
inline class A5(val x: Int, val y: Int)
inline class A6(x: Int, val y: Int)
inline class A7(vararg val x: Int)
inline class A8(<!NON_FINAL_MEMBER_IN_FINAL_CLASS!>open<!> val x: Int)
<!ABSENCE_OF_PRIMARY_CONSTRUCTOR_FOR_INLINE_CLASS!>inline<!> class A1
inline class A2<!INLINE_CLASS_CONSTRUCTOR_WRONG_PARAMETERS_SIZE!>()<!>
inline class A3(<!INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER!>x: Int<!>)
inline class A4(<!INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER!>var x: Int<!>)
inline class A5<!INLINE_CLASS_CONSTRUCTOR_WRONG_PARAMETERS_SIZE!>(val x: Int, val y: Int)<!>
inline class A6<!INLINE_CLASS_CONSTRUCTOR_WRONG_PARAMETERS_SIZE!>(x: Int, val y: Int)<!>
inline class A7(<!INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER!>vararg val x: Int<!>)
inline class A8(<!INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER!><!NON_FINAL_MEMBER_IN_FINAL_CLASS!>open<!> val x: Int<!>)
inline class A9(final val x: Int)
class B1 {
companion object {
inline class C1(val x: Int)
inner inline class C11(val x: Int)
<!INLINE_CLASS_NOT_TOP_LEVEL!>inline<!> class C1(val x: Int)
inner <!INLINE_CLASS_NOT_TOP_LEVEL!>inline<!> class C11(val x: Int)
}
inline class C2(val x: Int)
inner inline class C21(val x: Int)
<!INLINE_CLASS_NOT_TOP_LEVEL!>inline<!> class C2(val x: Int)
inner <!INLINE_CLASS_NOT_TOP_LEVEL!>inline<!> class C21(val x: Int)
}
object B2 {
inline class C3(val x: Int)
inner inline class C31(val x: Int)
<!INLINE_CLASS_NOT_TOP_LEVEL!>inline<!> class C3(val x: Int)
inner <!INLINE_CLASS_NOT_TOP_LEVEL!>inline<!> class C31(val x: Int)
}
fun foo() {
inline class C4(val x: Int)
<!INLINE_CLASS_NOT_TOP_LEVEL!>inline<!> class C4(val x: Int)
}
final inline class D0(val x: Int)
open inline class D1(val x: Int)
abstract inline class D2(val x: Int)
sealed inline class D3(val x: Int)
<!INLINE_CLASS_NOT_FINAL!>open<!> inline class D1(val x: Int)
<!INLINE_CLASS_NOT_FINAL!>abstract<!> inline class D2(val x: Int)
<!INLINE_CLASS_NOT_FINAL!>sealed<!> inline class D3(val x: Int)
<!INCOMPATIBLE_MODIFIERS!>inline<!> <!INCOMPATIBLE_MODIFIERS!>data<!> class D4(val x: String)
@@ -1,16 +0,0 @@
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses
inline class Foo<T>(val x: T)
inline class FooNullable<T>(val x: T?)
inline class FooGenericArray<T>(val x: Array<T>)
inline class FooGenericArray2<T>(val x: Array<Array<T>>)
inline class FooStarProjectedArray(val x: Array<*>)
inline class FooStarProjectedArray2(val x: Array<Array<*>>)
inline class Bar(val u: Unit)
inline class BarNullable(val u: Unit?)
inline class Baz(val u: Nothing)
inline class BazNullable(val u: Nothing?)
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses
inline class Foo<T>(val x: <!INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE!>T<!>)
@@ -2,7 +2,7 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
inline class Foo(val x: Int) {
inner class InnerC
inner object InnerO
inner interface InnerI
<!INNER_CLASS_INSIDE_INLINE_CLASS!>inner<!> class InnerC
<!INNER_CLASS_INSIDE_INLINE_CLASS!>inner<!> object InnerO
<!INNER_CLASS_INSIDE_INLINE_CLASS!>inner<!> interface InnerI
}
@@ -13,13 +13,13 @@ inline class Foo(val x: Int) : A, B {
val a0
get() = 0
val a1 = 0
<!PROPERTY_WITH_BACKING_FIELD_INSIDE_INLINE_CLASS!>val a1<!> = 0
var a2: Int
get() = 1
set(value) {}
var a3: Int = 0
<!PROPERTY_WITH_BACKING_FIELD_INSIDE_INLINE_CLASS!>var a3: Int<!> = 0
get() = 1
set(value) {
field = value
@@ -28,7 +28,7 @@ inline class Foo(val x: Int) : A, B {
override val goodSize: Int
get() = 0
override val badSize: Int = 0
<!PROPERTY_WITH_BACKING_FIELD_INSIDE_INLINE_CLASS!>override val badSize: Int<!> = 0
lateinit var lateinitProperty: String
<!PROPERTY_WITH_BACKING_FIELD_INSIDE_INLINE_CLASS!>lateinit var lateinitProperty: String<!>
}
@@ -1,21 +0,0 @@
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses
inline class Test1(val x: Test1)
inline class Test2A(val x: Test2B)
inline class Test2B(val x: Test2A)
inline class Test3A(val x: Test3B)
inline class Test3B(val x: Test3C)
inline class Test3C(val x: Test3A)
inline class TestNullable(val x: TestNullable?)
inline class TestRecursionInTypeArguments(val x: List<TestRecursionInTypeArguments>)
inline class TestRecursionInArray(val x: Array<TestRecursionInArray>)
inline class TestRecursionInUpperBounds<T : TestRecursionInUpperBounds<T>>(val x: T)
inline class Id<T>(val x: T)
inline class TestRecursionThroughId(val x: Id<TestRecursionThroughId>)
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses
inline class Test1(val x: <!INLINE_CLASS_CANNOT_BE_RECURSIVE!>Test1<!>)
@@ -2,32 +2,32 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
inline class IC1(val x: Any) {
fun box() {}
fun box(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>box<!>() {}
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>box<!>(x: Any) {}
fun unbox() {}
fun unbox(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>unbox<!>() {}
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>unbox<!>(x: Any) {}
override fun equals(other: Any?): Boolean = true
override fun hashCode(): Int = 0
override fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>equals<!>(other: Any?): Boolean = true
override fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>hashCode<!>(): Int = 0
}
inline class IC2(val x: Any) {
fun box(x: Any) {}
fun box(): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>box<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>box<!>(): Any = TODO()
fun unbox(x: Any) {}
fun unbox(): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>unbox<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>unbox<!>(): Any = TODO()
fun equals(my: Any, other: Any): Boolean = true
fun hashCode(a: Any): Int = 0
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>equals<!>(my: Any, other: Any): Boolean = true
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>hashCode<!>(a: Any): Int = 0
}
inline class IC3(val x: Any) {
fun box(x: Any): Any = TODO()
fun unbox(x: Any): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>box<!>(x: Any): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>unbox<!>(x: Any): Any = TODO()
fun equals(): Boolean = true
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>equals<!>(): Boolean = true
}
interface WithBox {
@@ -35,11 +35,11 @@ interface WithBox {
}
inline class IC4(val s: String) : WithBox {
override fun box(): String = ""
override fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>box<!>(): String = ""
}
inline class IC5(val a: String) {
constructor(i: Int) : this(i.toString()) {
constructor(i: Int) : this(i.toString()) <!SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_INLINE_CLASS!>{
TODO("something")
}
}
}<!>
}
@@ -8,7 +8,7 @@ expect inline class Foo1(val x: Int) {
expect inline class Foo2(val x: Int)
expect inline class Foo3
expect <!ABSENCE_OF_PRIMARY_CONSTRUCTOR_FOR_INLINE_CLASS!>inline<!> class Foo3
expect class NonInlineExpect
@@ -21,7 +21,7 @@ actual inline class Foo1(val x: Int) {
actual fun bar(): String = "Hello"
}
actual inline class Foo2(val x: String)
actual inline class Foo3
actual <!ABSENCE_OF_PRIMARY_CONSTRUCTOR_FOR_INLINE_CLASS!>inline<!> class Foo3
actual inline class NonInlineExpect(val x: Int)
@@ -14,4 +14,4 @@ value object InlineObject
value enum class InlineEnum
@JvmInline
value class NotVal(x: Int)
value class NotVal(<!INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER!>x: Int<!>)
@@ -26,9 +26,9 @@ object VarObject {
@JvmInline
value class Z(val data: Int) {
val testVal by Val()
var testVar by Var()
val testVal by <!DELEGATED_PROPERTY_INSIDE_INLINE_CLASS!>Val()<!>
var testVar by <!DELEGATED_PROPERTY_INSIDE_INLINE_CLASS!>Var()<!>
val testValBySingleton by ValObject
var testVarBySingleton by VarObject
val testValBySingleton by <!DELEGATED_PROPERTY_INSIDE_INLINE_CLASS!>ValObject<!>
var testVarBySingleton by <!DELEGATED_PROPERTY_INSIDE_INLINE_CLASS!>VarObject<!>
}
@@ -19,13 +19,13 @@ value class Foo(val x: Int) : A, B {
val a0
get() = 0
val a1 = 0
<!PROPERTY_WITH_BACKING_FIELD_INSIDE_INLINE_CLASS!>val a1<!> = 0
var a2: Int
get() = 1
set(value) {}
var a3: Int = 0
<!PROPERTY_WITH_BACKING_FIELD_INSIDE_INLINE_CLASS!>var a3: Int<!> = 0
get() = 1
set(value) {
field = value
@@ -34,7 +34,7 @@ value class Foo(val x: Int) : A, B {
override val goodSize: Int
get() = 0
override val badSize: Int = 0
<!PROPERTY_WITH_BACKING_FIELD_INSIDE_INLINE_CLASS!>override val badSize: Int<!> = 0
lateinit var lateinitProperty: String
<!PROPERTY_WITH_BACKING_FIELD_INSIDE_INLINE_CLASS!>lateinit var lateinitProperty: String<!>
}
@@ -1,38 +0,0 @@
// !SKIP_JAVAC
// !LANGUAGE: +InlineClasses
package kotlin.jvm
annotation class JvmInline
@JvmInline
value class Test1(val x: Test1)
@JvmInline
value class Test2A(val x: Test2B)
@JvmInline
value class Test2B(val x: Test2A)
@JvmInline
value class Test3A(val x: Test3B)
@JvmInline
value class Test3B(val x: Test3C)
@JvmInline
value class Test3C(val x: Test3A)
@JvmInline
value class TestNullable(val x: TestNullable?)
@JvmInline
value class TestRecursionInTypeArguments(val x: List<TestRecursionInTypeArguments>)
@JvmInline
value class TestRecursionInArray(val x: Array<TestRecursionInArray>)
@JvmInline
value class TestRecursionInUpperBounds<T : TestRecursionInUpperBounds<T>>(val x: T)
@JvmInline
value class Id<T>(val x: T)
@JvmInline
value class TestRecursionThroughId(val x: Id<TestRecursionThroughId>)
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !SKIP_JAVAC
// !LANGUAGE: +InlineClasses
@@ -8,34 +8,34 @@ annotation class JvmInline
@JvmInline
value class IC1(val x: Any) {
fun box() {}
fun box(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>box<!>() {}
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>box<!>(x: Any) {}
fun unbox() {}
fun unbox(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>unbox<!>() {}
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>unbox<!>(x: Any) {}
override fun equals(other: Any?): Boolean = true
override fun hashCode(): Int = 0
override fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>equals<!>(other: Any?): Boolean = true
override fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>hashCode<!>(): Int = 0
}
@JvmInline
value class IC2(val x: Any) {
fun box(x: Any) {}
fun box(): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>box<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>box<!>(): Any = TODO()
fun unbox(x: Any) {}
fun unbox(): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>unbox<!>(x: Any) {}
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>unbox<!>(): Any = TODO()
fun equals(my: Any, other: Any): Boolean = true
fun hashCode(a: Any): Int = 0
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>equals<!>(my: Any, other: Any): Boolean = true
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>hashCode<!>(a: Any): Int = 0
}
@JvmInline
value class IC3(val x: Any) {
fun box(x: Any): Any = TODO()
fun unbox(x: Any): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>box<!>(x: Any): Any = TODO()
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>unbox<!>(x: Any): Any = TODO()
fun equals(): Boolean = true
fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>equals<!>(): Boolean = true
}
interface WithBox {
@@ -44,12 +44,12 @@ interface WithBox {
@JvmInline
value class IC4(val s: String) : WithBox {
override fun box(): String = ""
override fun <!RESERVED_MEMBER_INSIDE_INLINE_CLASS!>box<!>(): String = ""
}
@JvmInline
value class IC5(val a: String) {
constructor(i: Int) : this(i.toString()) {
constructor(i: Int) : this(i.toString()) <!SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_INLINE_CLASS!>{
TODO("something")
}
}<!>
}
@@ -1,21 +0,0 @@
// !SKIP_JAVAC
// !LANGUAGE: +InlineClasses
package kotlin.jvm
annotation class JvmInline
abstract class AbstractBaseClass
open class OpenBaseClass
interface BaseInterface
@JvmInline
value class TestExtendsAbstractClass(val x: Int) : AbstractBaseClass()
@JvmInline
value class TestExtendsOpenClass(val x: Int) : OpenBaseClass()
@JvmInline
value class TestImplementsInterface(val x: Int) : BaseInterface
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !SKIP_JAVAC
// !LANGUAGE: +InlineClasses
@@ -10,7 +10,7 @@ interface IFoo
object FooImpl : IFoo
@JvmInline
value class Test1(val x: Any) : IFoo by FooImpl
value class Test1(val x: Any) : <!INLINE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION!>IFoo<!> by FooImpl
@JvmInline
value class Test2(val x: IFoo) : IFoo by x
value class Test2(val x: IFoo) : <!INLINE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION!>IFoo<!> by x
@@ -10,43 +10,43 @@ annotation class JvmInline
value class A0(val x: Int)
@JvmInline
value class A1
<!ABSENCE_OF_PRIMARY_CONSTRUCTOR_FOR_INLINE_CLASS!>value<!> class A1
@JvmInline
value class A2()
value class A2<!INLINE_CLASS_CONSTRUCTOR_WRONG_PARAMETERS_SIZE!>()<!>
@JvmInline
value class A3(x: Int)
value class A3(<!INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER!>x: Int<!>)
@JvmInline
value class A4(var x: Int)
value class A4(<!INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER!>var x: Int<!>)
@JvmInline
value class A5(val x: Int, val y: Int)
value class A5<!INLINE_CLASS_CONSTRUCTOR_WRONG_PARAMETERS_SIZE!>(val x: Int, val y: Int)<!>
@JvmInline
value class A6(x: Int, val y: Int)
value class A6<!INLINE_CLASS_CONSTRUCTOR_WRONG_PARAMETERS_SIZE!>(x: Int, val y: Int)<!>
@JvmInline
value class A7(vararg val x: Int)
value class A7(<!INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER!>vararg val x: Int<!>)
@JvmInline
value class A8(<!NON_FINAL_MEMBER_IN_FINAL_CLASS!>open<!> val x: Int)
value class A8(<!INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER!><!NON_FINAL_MEMBER_IN_FINAL_CLASS!>open<!> val x: Int<!>)
@JvmInline
value class A9(final val x: Int)
class B1 {
companion object {
@JvmInline
value class C1(val x: Int)
<!INLINE_CLASS_NOT_TOP_LEVEL!>value<!> class C1(val x: Int)
}
@JvmInline
value class C2(val x: Int)
<!INLINE_CLASS_NOT_TOP_LEVEL!>value<!> class C2(val x: Int)
}
object B2 {
@JvmInline
value class C3(val x: Int)
<!INLINE_CLASS_NOT_TOP_LEVEL!>value<!> class C3(val x: Int)
}
@JvmInline
final value class D0(val x: Int)
open value class D1(val x: Int)
abstract value class D2(val x: Int)
sealed value class D3(val x: Int)
<!INLINE_CLASS_NOT_FINAL!>open<!> value class D1(val x: Int)
<!INLINE_CLASS_NOT_FINAL!>abstract<!> value class D2(val x: Int)
<!INLINE_CLASS_NOT_FINAL!>sealed<!> value class D3(val x: Int)
value data class D4(val x: String)
@@ -1,31 +0,0 @@
// !SKIP_JAVAC
// !LANGUAGE: +InlineClasses
package kotlin.jvm
annotation class JvmInline
@JvmInline
value class Foo<T>(val x: T)
@JvmInline
value class FooNullable<T>(val x: T?)
@JvmInline
value class FooGenericArray<T>(val x: Array<T>)
@JvmInline
value class FooGenericArray2<T>(val x: Array<Array<T>>)
@JvmInline
value class FooStarProjectedArray(val x: Array<*>)
@JvmInline
value class FooStarProjectedArray2(val x: Array<Array<*>>)
@JvmInline
value class Bar(val u: Unit)
@JvmInline
value class BarNullable(val u: Unit?)
@JvmInline
value class Baz(val u: Nothing)
@JvmInline
value class BazNullable(val u: Nothing?)
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !SKIP_JAVAC
// !LANGUAGE: +InlineClasses