Revert "FIR/LC: create synthetic members of enum class"

This reverts commit 1b6ded60
This commit is contained in:
Yan Zhulanow
2022-03-03 21:14:48 +09:00
parent 736c6c4d29
commit f237631f05
13 changed files with 9 additions and 132 deletions
@@ -96,10 +96,8 @@ internal open class FirLightClassForSymbol(
val declaredMemberScope = classOrObjectSymbol.getDeclaredMemberScope()
val visibleDeclarations = declaredMemberScope.getCallableSymbols().applyIf(isEnum) {
// Technically, synthetic members of `enum` class, such as `values` or `valueOf`, are visible.
// They're just needed to be added later (to be in a backward-compatible order of members).
filterNot { function ->
function is KtFunctionSymbol && function.origin == KtSymbolOrigin.SOURCE_MEMBER_GENERATED &&
function is KtFunctionSymbol &&
(function.name == ENUM_VALUES || function.name == ENUM_VALUE_OF)
}
}.applyIf(classOrObjectSymbol.isObject) {
@@ -122,7 +120,6 @@ internal open class FirLightClassForSymbol(
addMethodsFromCompanionIfNeeded(result)
addMethodsFromEnumClass(result)
addMethodsFromDataClass(result)
addDelegatesToInterfaceMethods(result)
@@ -140,19 +137,6 @@ internal open class FirLightClassForSymbol(
}
}
private fun addMethodsFromEnumClass(result: MutableList<KtLightMethod>) {
if (!isEnum) return
analyzeWithSymbolAsContext(classOrObjectSymbol) {
val valuesAndValueOfFunctions = classOrObjectSymbol.getDeclaredMemberScope()
.getCallableSymbols { name -> name == ENUM_VALUES || name == ENUM_VALUE_OF }
.filter { it.origin == KtSymbolOrigin.SOURCE_MEMBER_GENERATED }
.filterIsInstance<KtFunctionSymbol>()
createMethods(valuesAndValueOfFunctions, result)
}
}
private fun addMethodsFromDataClass(result: MutableList<KtLightMethod>) {
if (!classOrObjectSymbol.isData) return
@@ -31,7 +31,7 @@ internal abstract class FirLightParameterBaseForSymbol(
protected val nullabilityType: NullabilityType
get() {
val nullabilityApplicable = !containingMethod.containingClass.let { it.isAnnotationType } &&
val nullabilityApplicable = !containingMethod.containingClass.let { it.isAnnotationType || it.isEnum } &&
!containingMethod.hasModifierProperty(PsiModifier.PRIVATE)
return if (nullabilityApplicable) {