K1/K2: add Enum.entries unconditionally and filter them out in tower
Before this commit, we added Enum.entries only in case when LanguageFeature.EnumEntries was ON (with an exception in K1/Java case). In this commit we add Enum.entries unconditionally, and in case the language feature is OFF we filter them out during tower resolve.
This commit is contained in:
+2
-3
@@ -31,8 +31,7 @@ import org.jetbrains.kotlin.utils.SmartList
|
||||
// We don't need to track lookups here since this scope used only for introduce special Enum class members
|
||||
class StaticScopeForKotlinEnum(
|
||||
storageManager: StorageManager,
|
||||
private val containingClass: ClassDescriptor,
|
||||
private val supportEnumEntries: Boolean
|
||||
private val containingClass: ClassDescriptor
|
||||
) : MemberScopeImpl() {
|
||||
init {
|
||||
assert(containingClass.kind == ClassKind.ENUM_CLASS) { "Class should be an enum: $containingClass" }
|
||||
@@ -45,7 +44,7 @@ class StaticScopeForKotlinEnum(
|
||||
}
|
||||
|
||||
private val properties: List<PropertyDescriptor> by storageManager.createLazyValue {
|
||||
if (supportEnumEntries) listOfNotNull(createEnumEntriesProperty(containingClass)) else emptyList()
|
||||
listOfNotNull(createEnumEntriesProperty(containingClass))
|
||||
}
|
||||
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) = functions + properties
|
||||
|
||||
-3
@@ -36,8 +36,5 @@ interface DeserializationConfiguration {
|
||||
val preserveDeclarationsOrdering: Boolean
|
||||
get() = false
|
||||
|
||||
val supportEnumEntries: Boolean
|
||||
get() = false
|
||||
|
||||
object Default : DeserializationConfiguration
|
||||
}
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ class DeserializedClassDescriptor(
|
||||
|
||||
private val staticScope =
|
||||
if (kind == ClassKind.ENUM_CLASS)
|
||||
StaticScopeForKotlinEnum(c.storageManager, this, c.components.configuration.supportEnumEntries)
|
||||
StaticScopeForKotlinEnum(c.storageManager, this)
|
||||
else
|
||||
MemberScope.Empty
|
||||
|
||||
|
||||
Reference in New Issue
Block a user