JVM IR: fix detection of enum entries in the same module

Use the new `IrClass.hasEnumEntries` flag added in the previous commit.

 #KT-61208 Fixed
This commit is contained in:
Alexander Udalov
2023-08-15 22:49:57 +02:00
committed by Space Team
parent c33c918bd4
commit 6219f7fc0d
21 changed files with 133 additions and 3 deletions
@@ -529,11 +529,12 @@ fun IrClass.isEnumClassWhichRequiresExternalEntries(): Boolean =
isEnumClass && (isFromJava() || !hasEnumEntriesFunction())
private fun IrClass.hasEnumEntriesFunction(): Boolean {
// Enums from other modules are always loaded with a property `entries` which has a getter `<get-entries>`.
// Enums from the current module will have a property `entries` if they are unlowered yet (i.e. enum is declared in another file
// which will be lowered after the file with the call site), or a function `<get-entries>` if they are already lowered.
return functions.any { it.isGetEntries() }
|| (properties.any { it.getter?.isGetEntries() == true } && isInCurrentModule())
// Enums from other modules have `entries` if and only if the flag `hasEnumEntries` is true.
return if (isInCurrentModule())
functions.any { it.isGetEntries() } || properties.any { it.getter?.isGetEntries() == true }
else hasEnumEntries
}
private fun IrSimpleFunction.isGetEntries(): Boolean =