[FE 1.0] Prohibit access to members of companion of enum from enum entry initializer

^KT-49461 Fixed
^KT-49110
This commit is contained in:
Dmitriy Novozhilov
2021-10-28 15:40:15 +03:00
committed by TeamCityServer
parent 4f0c3c3c0d
commit 58889a2b5c
14 changed files with 422 additions and 6 deletions
@@ -407,7 +407,15 @@ class ControlFlowInformationProviderImpl private constructor(
report(Errors.UNINITIALIZED_ENUM_ENTRY.on(element, classDescriptor), ctxt)
ClassKind.OBJECT -> if (classDescriptor.isCompanionObject) {
val container = classDescriptor.containingDeclaration
if (container is ClassDescriptor && container.kind == ClassKind.ENUM_CLASS) {
/*
* ProhibitAccessToEnumCompanionMembersInEnumConstructorCall feature enabled then UNINITIALIZED_ENUM_COMPANION
* will be reported from EnumCompanionInEnumConstructorCallChecker
*/
if (
container is ClassDescriptor &&
container.kind == ClassKind.ENUM_CLASS &&
!languageVersionSettings.supportsFeature(LanguageFeature.ProhibitAccessToEnumCompanionMembersInEnumConstructorCall)
) {
report(Errors.UNINITIALIZED_ENUM_COMPANION.on(element, container), ctxt)
}
}