FIR/LC: fix modality of enum class

enum class, which is extended by enum entries, should not be final.
(Those enum entries should be, instead.)

enum class itself wouldn't be instantiated, and thus it's technically
abstract, but having a private ctor() would be an option.
For the latter case, we can simply put no modality modifier.
This commit is contained in:
Jinseong Jeon
2021-09-06 22:06:39 -07:00
committed by Ilya Kirillov
parent 204c5952bf
commit 6342e6ecad
2 changed files with 25 additions and 14 deletions
@@ -53,7 +53,13 @@ internal class KtFirNamedClassOrObjectSymbol(
override val modality: Modality
get() = getModality(
FirResolvePhase.RAW_FIR,
if (classKind == KtClassKind.INTERFACE) Modality.ABSTRACT else Modality.FINAL
when (classKind) { // default modality
KtClassKind.INTERFACE -> Modality.ABSTRACT
// Enum class should not be `final`, since its entries extend it.
// It could be either `abstract` w/o ctor, or empty modality w/ private ctor.
KtClassKind.ENUM_CLASS -> Modality.OPEN
else -> Modality.FINAL
}
)
/* FirRegularClass visibility are not modified by STATUS only for Unknown so it can be taken from RAW */