diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt index 4dfde50464b..2b42d332e01 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt @@ -316,6 +316,12 @@ class DeclarationsConverter( } } + private fun LighterASTNode.hasValueParameters(): Boolean { + return getChildNodesByType(VALUE_PARAMETER_LIST).let { + it.isNotEmpty() && it.first().getChildNodesByType(VALUE_PARAMETER).isNotEmpty() + } + } + /***** DECLARATIONS *****/ /** * @see org.jetbrains.kotlin.parsing.KotlinParsing.parseClassOrObject @@ -417,9 +423,12 @@ class DeclarationsConverter( this.superTypeRefs += superTypeRefs + val secondaryConstructors = classBody.getChildNodesByType(SECONDARY_CONSTRUCTOR) val classWrapper = ClassWrapper( className, modifiers, classKind, primaryConstructor != null, - classBody.getChildNodesByType(SECONDARY_CONSTRUCTOR).isNotEmpty(), + secondaryConstructors.isNotEmpty(), + if (primaryConstructor != null) !primaryConstructor!!.hasValueParameters() + else secondaryConstructors.isEmpty() || secondaryConstructors.any { !it.hasValueParameters() }, selfType, delegatedSuperTypeRef ?: defaultDelegatedSuperTypeRef, superTypeCallEntry ) @@ -503,6 +512,7 @@ class DeclarationsConverter( val classWrapper = ClassWrapper( SpecialNames.NO_NAME_PROVIDED, modifiers, ClassKind.OBJECT, hasPrimaryConstructor = false, hasSecondaryConstructor = classBody.getChildNodesByType(SECONDARY_CONSTRUCTOR).isNotEmpty(), + hasDefaultConstructor = false, delegatedSelfTypeRef = delegatedType, delegatedSuperTypeRef = delegatedType, superTypeCallEntry = superTypeCallEntry @@ -541,6 +551,15 @@ class DeclarationsConverter( session = baseSession returnTypeRef = classWrapper.delegatedSelfTypeRef name = enumEntryName + symbol = FirVariableSymbol(CallableId(context.currentClassId, enumEntryName)) + status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply { + isStatic = true + } + if (classWrapper.hasDefaultConstructor && enumEntry.getChildNodeByType(INITIALIZER_LIST) == null && + modifiers.annotations.isEmpty() && classBodyNode == null + ) { + return@buildEnumEntry + } initializer = withChildClassName(enumEntryName) { buildAnonymousObject { source = this@buildEnumEntry.source @@ -552,6 +571,7 @@ class DeclarationsConverter( val enumClassWrapper = ClassWrapper( enumEntryName, modifiers, ClassKind.ENUM_ENTRY, hasPrimaryConstructor = true, hasSecondaryConstructor = classBodyNode.getChildNodesByType(SECONDARY_CONSTRUCTOR).isNotEmpty(), + hasDefaultConstructor = false, delegatedSelfTypeRef = buildResolvedTypeRef { type = ConeClassLikeTypeImpl( this@buildAnonymousObject.symbol.toLookupTag(), @@ -567,10 +587,6 @@ class DeclarationsConverter( classBodyNode?.also { declarations += convertClassBody(it, enumClassWrapper) } } } - symbol = FirVariableSymbol(CallableId(context.currentClassId, enumEntryName)) - status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply { - isStatic = true - } } } diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/ClassWrapper.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/ClassWrapper.kt index 7439c9c6f05..aa98e5e32e3 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/ClassWrapper.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/fir/ClassWrapper.kt @@ -21,6 +21,7 @@ class ClassWrapper( private val classKind: ClassKind, val hasPrimaryConstructor: Boolean, val hasSecondaryConstructor: Boolean, + val hasDefaultConstructor: Boolean, val delegatedSelfTypeRef: FirTypeRef, val delegatedSuperTypeRef: FirTypeRef, val superTypeCallEntry: MutableList diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index cc877668cae..cdc5d19a64e 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -154,16 +154,25 @@ class RawFirBuilder( delegatedSuperType: FirTypeRef?, delegatedSelfType: FirResolvedTypeRef?, owner: KtClassOrObject, hasPrimaryConstructor: Boolean, ): FirDeclaration { return when (this) { - is KtSecondaryConstructor -> toFirConstructor( - delegatedSuperType, - delegatedSelfType ?: buildErrorTypeRef { - source = this@toFirDeclaration.toFirSourceElement() - diagnostic = FirSimpleDiagnostic("Constructor in object", DiagnosticKind.ConstructorInObject) - }, - owner, - hasPrimaryConstructor, - ) - is KtEnumEntry -> toFirEnumEntry(delegatedSelfType!!) + is KtSecondaryConstructor -> { + toFirConstructor( + delegatedSuperType, + delegatedSelfType ?: buildErrorTypeRef { + source = this@toFirDeclaration.toFirSourceElement() + diagnostic = FirSimpleDiagnostic("Constructor in object", DiagnosticKind.ConstructorInObject) + }, + owner, + hasPrimaryConstructor, + ) + } + is KtEnumEntry -> { + val primaryConstructor = owner.primaryConstructor + val ownerClassHasDefaultConstructor = + primaryConstructor?.valueParameters?.isEmpty() ?: owner.secondaryConstructors.let { constructors -> + constructors.isEmpty() || constructors.any { it.valueParameters.isEmpty() } + } + toFirEnumEntry(delegatedSelfType!!, ownerClassHasDefaultConstructor) + } else -> convert() } } @@ -518,13 +527,26 @@ class RawFirBuilder( } } - private fun KtEnumEntry.toFirEnumEntry(delegatedEnumSelfTypeRef: FirResolvedTypeRef): FirDeclaration { + private fun KtEnumEntry.toFirEnumEntry( + delegatedEnumSelfTypeRef: FirResolvedTypeRef, + ownerClassHasDefaultConstructor: Boolean + ): FirDeclaration { val ktEnumEntry = this@toFirEnumEntry return buildEnumEntry { source = toFirSourceElement() session = baseSession returnTypeRef = delegatedEnumSelfTypeRef name = nameAsSafeName + status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply { + isStatic = true + } + symbol = FirVariableSymbol(callableIdForName(nameAsSafeName)) + // NB: not sure should annotations be on enum entry itself, or on its corresponding object + if (ownerClassHasDefaultConstructor && ktEnumEntry.initializerList == null && + ktEnumEntry.annotationEntries.isEmpty() && ktEnumEntry.body == null + ) { + return@buildEnumEntry + } initializer = withChildClassName(nameAsSafeName) { buildAnonymousObject { source = toFirSourceElement() @@ -559,12 +581,6 @@ class RawFirBuilder( } } } - status = FirDeclarationStatusImpl( - Visibilities.PUBLIC, Modality.FINAL, - ).apply { - isStatic = true - } - symbol = FirVariableSymbol(callableIdForName(nameAsSafeName)) } } diff --git a/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums.kt b/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums.kt index d9193ae313b..e0ab031a924 100644 --- a/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums.kt +++ b/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums.kt @@ -30,4 +30,17 @@ enum class Planet(val m: Double, internal val r: Double) { companion object { const val G = 6.67e-11 } +} + +enum class PseudoInsn(val signature: String = "()V") { + FIX_STACK_BEFORE_JUMP, + FAKE_ALWAYS_TRUE_IFEQ("()I"), + FAKE_ALWAYS_FALSE_IFEQ("()I"), + SAVE_STACK_BEFORE_TRY, + RESTORE_STACK_IN_TRY_CATCH, + STORE_NOT_NULL, + AS_NOT_NULL("(Ljava/lang/Object;)Ljava/lang/Object;") + ; + + fun emit() {} } \ No newline at end of file diff --git a/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums.txt b/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums.txt index 38dcb3f06c1..865efaa02fe 100644 --- a/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums.txt +++ b/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums.txt @@ -4,27 +4,9 @@ FILE: enums.kt super|>() } - public final static enum entry FIRST: R|Order| = object : R|Order| { - public? constructor(): R|anonymous| { - super() - } - - } - - public final static enum entry SECOND: R|Order| = object : R|Order| { - public? constructor(): R|anonymous| { - super() - } - - } - - public final static enum entry THIRD: R|Order| = object : R|Order| { - public? constructor(): R|anonymous| { - super() - } - - } - + public final static enum entry FIRST: R|Order| + public final static enum entry SECOND: R|Order| + public final static enum entry THIRD: R|Order| public final static fun values(): R|kotlin/Array| { } @@ -98,3 +80,70 @@ FILE: enums.kt } } + public? final? enum class PseudoInsn : R|kotlin/Enum| { + public? constructor(signature: String = String(()V)): R|PseudoInsn| { + super|>() + } + + public? final? val signature: String = R|/signature| + public? get(): String + + public final static enum entry FIX_STACK_BEFORE_JUMP: R|PseudoInsn| = object : R|PseudoInsn| { + public? constructor(): R|anonymous| { + super() + } + + } + + public final static enum entry FAKE_ALWAYS_TRUE_IFEQ: R|PseudoInsn| = object : R|PseudoInsn| { + public? constructor(): R|anonymous| { + super(String(()I)) + } + + } + + public final static enum entry FAKE_ALWAYS_FALSE_IFEQ: R|PseudoInsn| = object : R|PseudoInsn| { + public? constructor(): R|anonymous| { + super(String(()I)) + } + + } + + public final static enum entry SAVE_STACK_BEFORE_TRY: R|PseudoInsn| = object : R|PseudoInsn| { + public? constructor(): R|anonymous| { + super() + } + + } + + public final static enum entry RESTORE_STACK_IN_TRY_CATCH: R|PseudoInsn| = object : R|PseudoInsn| { + public? constructor(): R|anonymous| { + super() + } + + } + + public final static enum entry STORE_NOT_NULL: R|PseudoInsn| = object : R|PseudoInsn| { + public? constructor(): R|anonymous| { + super() + } + + } + + public final static enum entry AS_NOT_NULL: R|PseudoInsn| = object : R|PseudoInsn| { + public? constructor(): R|anonymous| { + super(String((Ljava/lang/Object;)Ljava/lang/Object;)) + } + + } + + public? final? fun emit(): R|kotlin/Unit| { + } + + public final static fun values(): R|kotlin/Array| { + } + + public final static fun valueOf(value: R|kotlin/String|): R|PseudoInsn| { + } + + } diff --git a/compiler/fir/resolve/testData/resolve/enum.kt b/compiler/fir/resolve/testData/resolve/enum.kt index 8729baeccde..ff83577c41e 100644 --- a/compiler/fir/resolve/testData/resolve/enum.kt +++ b/compiler/fir/resolve/testData/resolve/enum.kt @@ -13,4 +13,25 @@ enum class SomeEnum(val x: Some) { }; abstract fun check(y: Some): Boolean +} + +enum class E { + A; // no constructor call needed + constructor() +} + +enum class EnumClass { + E1 { + override fun foo() = 1 + override val bar: String = "a" + }, + + E2 { + + }, + + E3(); + + abstract fun foo(): Int + abstract val bar: String } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/enum.txt b/compiler/fir/resolve/testData/resolve/enum.txt index 25b656fcb0f..5d081869343 100644 --- a/compiler/fir/resolve/testData/resolve/enum.txt +++ b/compiler/fir/resolve/testData/resolve/enum.txt @@ -52,3 +52,61 @@ FILE: enum.kt } } + public final enum class E : R|kotlin/Enum| { + public final static enum entry A: R|E| + private constructor(): R|E| { + super|>() + } + + public final static fun values(): R|kotlin/Array| { + } + + public final static fun valueOf(value: R|kotlin/String|): R|E| { + } + + } + public final enum class EnumClass : R|kotlin/Enum| { + private constructor(): R|EnumClass| { + super|>() + } + + public final static enum entry E1: R|EnumClass| = object : R|EnumClass| { + private constructor(): R|anonymous| { + super() + } + + public final override fun foo(): R|kotlin/Int| { + ^foo Int(1) + } + + public final override val bar: R|kotlin/String| = String(a) + public get(): R|kotlin/String| + + } + + public final static enum entry E2: R|EnumClass| = object : R|EnumClass| { + private constructor(): R|anonymous| { + super() + } + + } + + public final static enum entry E3: R|EnumClass| = object : R|EnumClass| { + private constructor(): R|anonymous| { + super() + } + + } + + public abstract fun foo(): R|kotlin/Int| + + public abstract val bar: R|kotlin/String| + public get(): R|kotlin/String| + + public final static fun values(): R|kotlin/Array| { + } + + public final static fun valueOf(value: R|kotlin/String|): R|EnumClass| { + } + + } diff --git a/compiler/fir/resolve/testData/resolve/enumWithCompanion.txt b/compiler/fir/resolve/testData/resolve/enumWithCompanion.txt index 46559175839..dddd5211571 100644 --- a/compiler/fir/resolve/testData/resolve/enumWithCompanion.txt +++ b/compiler/fir/resolve/testData/resolve/enumWithCompanion.txt @@ -4,20 +4,8 @@ FILE: enumWithCompanion.kt super|>() } - public final static enum entry A: R|EC| = object : R|EC| { - private constructor(): R|anonymous| { - super() - } - - } - - public final static enum entry B: R|EC| = object : R|EC| { - private constructor(): R|anonymous| { - super() - } - - } - + public final static enum entry A: R|EC| + public final static enum entry B: R|EC| public final companion object Companion : R|kotlin/Any| { private constructor(): R|EC.Companion| { super() diff --git a/compiler/fir/resolve/testData/resolve/exhaustiveWhenAndFlexibleType.txt b/compiler/fir/resolve/testData/resolve/exhaustiveWhenAndFlexibleType.txt index d445769fc6c..9e39732060b 100644 --- a/compiler/fir/resolve/testData/resolve/exhaustiveWhenAndFlexibleType.txt +++ b/compiler/fir/resolve/testData/resolve/exhaustiveWhenAndFlexibleType.txt @@ -4,27 +4,9 @@ FILE: main.kt super|>() } - public final static enum entry A: R|E| = object : R|E| { - private constructor(): R|anonymous| { - super() - } - - } - - public final static enum entry B: R|E| = object : R|E| { - private constructor(): R|anonymous| { - super() - } - - } - - public final static enum entry C: R|E| = object : R|E| { - private constructor(): R|anonymous| { - super() - } - - } - + public final static enum entry A: R|E| + public final static enum entry B: R|E| + public final static enum entry C: R|E| public final static fun values(): R|kotlin/Array| { } diff --git a/compiler/fir/resolve/testData/resolve/exhaustiveness_enum.txt b/compiler/fir/resolve/testData/resolve/exhaustiveness_enum.txt index ceb55382f58..c0ae4f790ca 100644 --- a/compiler/fir/resolve/testData/resolve/exhaustiveness_enum.txt +++ b/compiler/fir/resolve/testData/resolve/exhaustiveness_enum.txt @@ -4,27 +4,9 @@ FILE: exhaustiveness_enum.kt super|>() } - public final static enum entry A: R|Enum| = object : R|Enum| { - private constructor(): R|anonymous| { - super() - } - - } - - public final static enum entry B: R|Enum| = object : R|Enum| { - private constructor(): R|anonymous| { - super() - } - - } - - public final static enum entry C: R|Enum| = object : R|Enum| { - private constructor(): R|anonymous| { - super() - } - - } - + public final static enum entry A: R|Enum| + public final static enum entry B: R|Enum| + public final static enum entry C: R|Enum| public final static fun values(): R|kotlin/Array| { } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/enumEntryUse.txt b/compiler/fir/resolve/testData/resolve/expresssions/enumEntryUse.txt index 87a1c7b4306..65a7451968c 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/enumEntryUse.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/enumEntryUse.txt @@ -4,20 +4,8 @@ FILE: enumEntryUse.kt super|>() } - public final static enum entry FIRST: R|TestEnum| = object : R|TestEnum| { - private constructor(): R|anonymous| { - super() - } - - } - - public final static enum entry SECOND: R|TestEnum| = object : R|TestEnum| { - private constructor(): R|anonymous| { - super() - } - - } - + public final static enum entry FIRST: R|TestEnum| + public final static enum entry SECOND: R|TestEnum| public final static enum entry THIRD: R|TestEnum| = object : R|TestEnum| { private constructor(): R|anonymous| { super() diff --git a/compiler/fir/resolve/testData/resolve/expresssions/enumValues.txt b/compiler/fir/resolve/testData/resolve/expresssions/enumValues.txt index 8130ce0313a..1e8da670215 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/enumValues.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/enumValues.txt @@ -4,27 +4,9 @@ FILE: enumValues.kt super|>() } - public final static enum entry FIRST: R|MyEnum| = object : R|MyEnum| { - private constructor(): R|anonymous| { - super() - } - - } - - public final static enum entry SECOND: R|MyEnum| = object : R|MyEnum| { - private constructor(): R|anonymous| { - super() - } - - } - - public final static enum entry LAST: R|MyEnum| = object : R|MyEnum| { - private constructor(): R|anonymous| { - super() - } - - } - + public final static enum entry FIRST: R|MyEnum| + public final static enum entry SECOND: R|MyEnum| + public final static enum entry LAST: R|MyEnum| public final fun bar(): R|kotlin/Int| { ^bar Int(42) } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/qualifiedExpressions.txt b/compiler/fir/resolve/testData/resolve/expresssions/qualifiedExpressions.txt index 48039858658..c442a47f482 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/qualifiedExpressions.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/qualifiedExpressions.txt @@ -33,13 +33,7 @@ FILE: qualifiedExpressions.kt super|>() } - public final static enum entry entry: R|a/b/E| = object : R|a/b/E| { - private constructor(): R|anonymous| { - super() - } - - } - + public final static enum entry entry: R|a/b/E| public final static fun values(): R|kotlin/Array| { } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/qualifierPriority.txt b/compiler/fir/resolve/testData/resolve/expresssions/qualifierPriority.txt index f28896266ab..bd437213061 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/qualifierPriority.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/qualifierPriority.txt @@ -66,13 +66,7 @@ FILE: qualifierPriority.kt super|>() } - public final static enum entry H: R|G| = object : R|G| { - private constructor(): R|anonymous| { - super() - } - - } - + public final static enum entry H: R|G| public final fun foo(): R|kotlin/Unit| { R|/G.values|() } diff --git a/compiler/fir/resolve/testData/resolve/fromBuilder/enums.txt b/compiler/fir/resolve/testData/resolve/fromBuilder/enums.txt index 103ac138020..63a3dbc682c 100644 --- a/compiler/fir/resolve/testData/resolve/fromBuilder/enums.txt +++ b/compiler/fir/resolve/testData/resolve/fromBuilder/enums.txt @@ -4,27 +4,9 @@ FILE: enums.kt super|>() } - public final static enum entry FIRST: R|Order| = object : R|Order| { - private constructor(): R|anonymous| { - super() - } - - } - - public final static enum entry SECOND: R|Order| = object : R|Order| { - private constructor(): R|anonymous| { - super() - } - - } - - public final static enum entry THIRD: R|Order| = object : R|Order| { - private constructor(): R|anonymous| { - super() - } - - } - + public final static enum entry FIRST: R|Order| + public final static enum entry SECOND: R|Order| + public final static enum entry THIRD: R|Order| public final static fun values(): R|kotlin/Array| { } diff --git a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum1.kt b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum1.kt index f5678f933cd..6491d8e0cc9 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum1.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum1.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR enum class A { ONE, TWO; diff --git a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum2.kt b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum2.kt index 5d9b309324a..95eb4b9c827 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum2.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnEnum2.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR enum class A { ONE, TWO diff --git a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum1.kt b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum1.kt index 928d0099ce5..d627dad85a8 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum1.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum1.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR import A.ONE enum class A { diff --git a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum2.kt b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum2.kt index 1ee4cd1d931..53ecfc65908 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum2.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnImportedEnum2.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR import A.ONE enum class A { diff --git a/compiler/testData/codegen/box/enum/abstractNestedClass.kt b/compiler/testData/codegen/box/enum/abstractNestedClass.kt index d28c2710070..3994bd54e17 100644 --- a/compiler/testData/codegen/box/enum/abstractNestedClass.kt +++ b/compiler/testData/codegen/box/enum/abstractNestedClass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR enum class E { ENTRY; diff --git a/compiler/testData/codegen/box/enum/asReturnExpression.kt b/compiler/testData/codegen/box/enum/asReturnExpression.kt index 620ab72aa9b..c001e02763a 100644 --- a/compiler/testData/codegen/box/enum/asReturnExpression.kt +++ b/compiler/testData/codegen/box/enum/asReturnExpression.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // http://youtrack.jetbrains.com/issue/KT-2167 enum class Season { diff --git a/compiler/testData/codegen/box/enum/inPackage.kt b/compiler/testData/codegen/box/enum/inPackage.kt index 7100907abad..388eb0a0dd3 100644 --- a/compiler/testData/codegen/box/enum/inPackage.kt +++ b/compiler/testData/codegen/box/enum/inPackage.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR package test enum class Season { diff --git a/compiler/testData/codegen/box/enum/inner.kt b/compiler/testData/codegen/box/enum/inner.kt index 0656467258f..01ef380fbc3 100644 --- a/compiler/testData/codegen/box/enum/inner.kt +++ b/compiler/testData/codegen/box/enum/inner.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class A { enum class E { OK diff --git a/compiler/testData/codegen/box/enum/innerWithExistingClassObject.kt b/compiler/testData/codegen/box/enum/innerWithExistingClassObject.kt index d0fe0d390ba..139345cc14a 100644 --- a/compiler/testData/codegen/box/enum/innerWithExistingClassObject.kt +++ b/compiler/testData/codegen/box/enum/innerWithExistingClassObject.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class A { companion object {} enum class E { diff --git a/compiler/testData/codegen/box/enum/kt18731.kt b/compiler/testData/codegen/box/enum/kt18731.kt index 4e574f0a59d..bc98fc4c1b8 100644 --- a/compiler/testData/codegen/box/enum/kt18731.kt +++ b/compiler/testData/codegen/box/enum/kt18731.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR enum class Bar { ONE, TWO diff --git a/compiler/testData/codegen/box/enum/simple.kt b/compiler/testData/codegen/box/enum/simple.kt index 082ba0a81fa..ed48d29a5d9 100644 --- a/compiler/testData/codegen/box/enum/simple.kt +++ b/compiler/testData/codegen/box/enum/simple.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR enum class Season { WINTER, SPRING, diff --git a/compiler/testData/codegen/box/enum/sortEnumEntries.kt b/compiler/testData/codegen/box/enum/sortEnumEntries.kt index cc000d601b0..e50f3b52f89 100644 --- a/compiler/testData/codegen/box/enum/sortEnumEntries.kt +++ b/compiler/testData/codegen/box/enum/sortEnumEntries.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/enum/toString.kt b/compiler/testData/codegen/box/enum/toString.kt index 7520b6492eb..b4890365b12 100644 --- a/compiler/testData/codegen/box/enum/toString.kt +++ b/compiler/testData/codegen/box/enum/toString.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR enum class State { O, K diff --git a/compiler/testData/codegen/box/innerNested/nestedEnumConstant.kt b/compiler/testData/codegen/box/innerNested/nestedEnumConstant.kt index 3bca9ea9839..d8ae583f3d5 100644 --- a/compiler/testData/codegen/box/innerNested/nestedEnumConstant.kt +++ b/compiler/testData/codegen/box/innerNested/nestedEnumConstant.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class Outer { enum class Nested { O, diff --git a/compiler/testData/codegen/box/when/emptyWhen.kt b/compiler/testData/codegen/box/when/emptyWhen.kt index de8260a03e7..62ab58b6bf3 100644 --- a/compiler/testData/codegen/box/when/emptyWhen.kt +++ b/compiler/testData/codegen/box/when/emptyWhen.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR enum class A { X1, X2 } fun box(): String { diff --git a/compiler/testData/codegen/box/when/enumOptimization/nonConstantEnum.kt b/compiler/testData/codegen/box/when/enumOptimization/nonConstantEnum.kt index 93e0ddf28b2..f613b0c7f4f 100644 --- a/compiler/testData/codegen/box/when/enumOptimization/nonConstantEnum.kt +++ b/compiler/testData/codegen/box/when/enumOptimization/nonConstantEnum.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // CHECK_CASES_COUNT: function=box count=0 // CHECK_IF_COUNT: function=box count=1 diff --git a/compiler/testData/codegen/box/when/enumOptimization/subjectAny.kt b/compiler/testData/codegen/box/when/enumOptimization/subjectAny.kt index 13616def87a..1a18c698481 100644 --- a/compiler/testData/codegen/box/when/enumOptimization/subjectAny.kt +++ b/compiler/testData/codegen/box/when/enumOptimization/subjectAny.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // CHECK_CASES_COUNT: function=foo count=0 // CHECK_IF_COUNT: function=foo count=3 diff --git a/compiler/testData/diagnostics/tests/enum/interfaceWithEnumKeyword.fir.kt b/compiler/testData/diagnostics/tests/enum/interfaceWithEnumKeyword.fir.kt index 880df713f12..8db080692bf 100644 --- a/compiler/testData/diagnostics/tests/enum/interfaceWithEnumKeyword.fir.kt +++ b/compiler/testData/diagnostics/tests/enum/interfaceWithEnumKeyword.fir.kt @@ -1,6 +1,6 @@ enum interface Some { // Enum part - D; + D; // Interface like part fun test() diff --git a/compiler/testData/ir/irText/classes/enum.fir.txt b/compiler/testData/ir/irText/classes/enum.fir.txt index 6be05a07282..ce23f80143d 100644 --- a/compiler/testData/ir/irText/classes/enum.fir.txt +++ b/compiler/testData/ir/irText/classes/enum.fir.txt @@ -7,19 +7,11 @@ FILE fqName: fileName:/enum.kt : .TestEnum1 INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestEnum1 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestEnum1>]' ENUM_ENTRY name:TEST1 - class: CLASS ENUM_ENTRY name:TEST1 modality:FINAL visibility:private superTypes:[.TestEnum1] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnum1.TEST1 - CONSTRUCTOR visibility:private <> () returnType:. [primary] - BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestEnum1' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:TEST1 modality:FINAL visibility:private superTypes:[.TestEnum1]' + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestEnum1' ENUM_ENTRY name:TEST2 - class: CLASS ENUM_ENTRY name:TEST2 modality:FINAL visibility:private superTypes:[.TestEnum1] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnum1.TEST2 - CONSTRUCTOR visibility:private <> () returnType:. [primary] - BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestEnum1' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:TEST2 modality:FINAL visibility:private superTypes:[.TestEnum1]' + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestEnum1' FUN name:values visibility:public modality:FINAL <> ($this:.TestEnum1) returnType:kotlin.Array<.TestEnum1> $this: VALUE_PARAMETER name: type:.TestEnum1 BLOCK_BODY diff --git a/compiler/testData/ir/irText/classes/enumClassModality.fir.txt b/compiler/testData/ir/irText/classes/enumClassModality.fir.txt index 34959cfe1de..0693f9161fe 100644 --- a/compiler/testData/ir/irText/classes/enumClassModality.fir.txt +++ b/compiler/testData/ir/irText/classes/enumClassModality.fir.txt @@ -7,12 +7,8 @@ FILE fqName: fileName:/enumClassModality.kt : .TestFinalEnum1 INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestFinalEnum1 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestFinalEnum1>]' ENUM_ENTRY name:X1 - class: CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:private superTypes:[.TestFinalEnum1] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestFinalEnum1.X1 - CONSTRUCTOR visibility:private <> () returnType:. [primary] - BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestFinalEnum1' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:private superTypes:[.TestFinalEnum1]' + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestFinalEnum1' FUN name:values visibility:public modality:FINAL <> ($this:.TestFinalEnum1) returnType:kotlin.Array<.TestFinalEnum1> $this: VALUE_PARAMETER name: type:.TestFinalEnum1 BLOCK_BODY @@ -130,12 +126,8 @@ FILE fqName: fileName:/enumClassModality.kt : .TestFinalEnum3 INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestFinalEnum3 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestFinalEnum3>]' ENUM_ENTRY name:X1 - class: CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:private superTypes:[.TestFinalEnum3] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestFinalEnum3.X1 - CONSTRUCTOR visibility:private <> () returnType:. [primary] - BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestFinalEnum3' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:private superTypes:[.TestFinalEnum3]' + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestFinalEnum3' FUN name:doStuff visibility:public modality:FINAL <> ($this:.TestFinalEnum3) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.TestFinalEnum3 BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.fir.txt b/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.fir.txt index 3900d869d44..031056c4d6f 100644 --- a/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.fir.txt @@ -7,33 +7,17 @@ FILE fqName: fileName:/enumsInAnnotationArguments.kt : .En INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<.En>]' ENUM_ENTRY name:A - class: CLASS ENUM_ENTRY name:A modality:FINAL visibility:private superTypes:[.En] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.En.A - CONSTRUCTOR visibility:private <> () returnType:. [primary] - BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:A modality:FINAL visibility:private superTypes:[.En]' + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' ENUM_ENTRY name:B - class: CLASS ENUM_ENTRY name:B modality:FINAL visibility:private superTypes:[.En] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.En.B - CONSTRUCTOR visibility:private <> () returnType:. [primary] - BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:B modality:FINAL visibility:private superTypes:[.En]' + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' ENUM_ENTRY name:C - class: CLASS ENUM_ENTRY name:C modality:FINAL visibility:private superTypes:[.En] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.En.C - CONSTRUCTOR visibility:private <> () returnType:. [primary] - BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:C modality:FINAL visibility:private superTypes:[.En]' + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' ENUM_ENTRY name:D - class: CLASS ENUM_ENTRY name:D modality:FINAL visibility:private superTypes:[.En] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.En.D - CONSTRUCTOR visibility:private <> () returnType:. [primary] - BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:D modality:FINAL visibility:private superTypes:[.En]' + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' FUN name:values visibility:public modality:FINAL <> ($this:.En) returnType:kotlin.Array<.En> $this: VALUE_PARAMETER name: type:.En BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/multiplatform/expectedEnumClass.fir.txt b/compiler/testData/ir/irText/declarations/multiplatform/expectedEnumClass.fir.txt index c883ff4af21..e3f1e2214b2 100644 --- a/compiler/testData/ir/irText/declarations/multiplatform/expectedEnumClass.fir.txt +++ b/compiler/testData/ir/irText/declarations/multiplatform/expectedEnumClass.fir.txt @@ -7,19 +7,11 @@ FILE fqName: fileName:/expectedEnumClass.kt : .MyEnum INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:MyEnum modality:FINAL visibility:public [expect] superTypes:[kotlin.Enum<.MyEnum>]' ENUM_ENTRY name:FOO - class: CLASS ENUM_ENTRY name:FOO modality:FINAL visibility:private superTypes:[.MyEnum] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyEnum.FOO - CONSTRUCTOR visibility:private <> () returnType:. [primary] - BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .MyEnum' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:FOO modality:FINAL visibility:private superTypes:[.MyEnum]' + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .MyEnum' ENUM_ENTRY name:BAR - class: CLASS ENUM_ENTRY name:BAR modality:FINAL visibility:private superTypes:[.MyEnum] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyEnum.BAR - CONSTRUCTOR visibility:private <> () returnType:. [primary] - BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .MyEnum' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:BAR modality:FINAL visibility:private superTypes:[.MyEnum]' + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .MyEnum' FUN name:values visibility:public modality:FINAL <> ($this:.MyEnum) returnType:kotlin.Array<.MyEnum> $this: VALUE_PARAMETER name: type:.MyEnum BLOCK_BODY @@ -69,26 +61,14 @@ FILE fqName: fileName:/expectedEnumClass.kt : .MyEnum INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:MyEnum modality:FINAL visibility:public superTypes:[kotlin.Enum<.MyEnum>]' ENUM_ENTRY name:FOO - class: CLASS ENUM_ENTRY name:FOO modality:FINAL visibility:private superTypes:[.MyEnum] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyEnum.FOO - CONSTRUCTOR visibility:private <> () returnType:. [primary] - BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .MyEnum' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:FOO modality:FINAL visibility:private superTypes:[.MyEnum]' + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .MyEnum' ENUM_ENTRY name:BAR - class: CLASS ENUM_ENTRY name:BAR modality:FINAL visibility:private superTypes:[.MyEnum] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyEnum.BAR - CONSTRUCTOR visibility:private <> () returnType:. [primary] - BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .MyEnum' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:BAR modality:FINAL visibility:private superTypes:[.MyEnum]' + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .MyEnum' ENUM_ENTRY name:BAZ - class: CLASS ENUM_ENTRY name:BAZ modality:FINAL visibility:private superTypes:[.MyEnum] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyEnum.BAZ - CONSTRUCTOR visibility:private <> () returnType:. [primary] - BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .MyEnum' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:BAZ modality:FINAL visibility:private superTypes:[.MyEnum]' + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .MyEnum' FUN name:values visibility:public modality:FINAL <> ($this:.MyEnum) returnType:kotlin.Array<.MyEnum> $this: VALUE_PARAMETER name: type:.MyEnum BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt b/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt index 6b9c0d77c03..354c8a01342 100644 --- a/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt +++ b/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt @@ -26,12 +26,8 @@ FILE fqName: fileName:/objectAsCallable.kt : .En INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<.En>]' ENUM_ENTRY name:X - class: CLASS ENUM_ENTRY name:X modality:FINAL visibility:private superTypes:[.En] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.En.X - CONSTRUCTOR visibility:private <> () returnType:. [primary] - BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:X modality:FINAL visibility:private superTypes:[.En]' + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .En' FUN name:values visibility:public modality:FINAL <> ($this:.En) returnType:kotlin.Array<.En> $this: VALUE_PARAMETER name: type:.En BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/values.fir.txt b/compiler/testData/ir/irText/expressions/values.fir.txt index 6d551e4df91..6e94be70a45 100644 --- a/compiler/testData/ir/irText/expressions/values.fir.txt +++ b/compiler/testData/ir/irText/expressions/values.fir.txt @@ -7,12 +7,8 @@ FILE fqName: fileName:/values.kt : .Enum INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:Enum modality:FINAL visibility:public superTypes:[kotlin.Enum<.Enum>]' ENUM_ENTRY name:A - class: CLASS ENUM_ENTRY name:A modality:FINAL visibility:private superTypes:[.Enum] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Enum.A - CONSTRUCTOR visibility:private <> () returnType:. [primary] - BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .Enum' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:A modality:FINAL visibility:private superTypes:[.Enum]' + init: EXPRESSION_BODY + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .Enum' FUN name:values visibility:public modality:FINAL <> ($this:.Enum) returnType:kotlin.Array<.Enum> $this: VALUE_PARAMETER name: type:.Enum BLOCK_BODY