Create non-default getter for Enum.values property
#KT-9687 Fixed
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
enum class Variants {
|
||||
O, K;
|
||||
companion object {
|
||||
val valueStr = values[0].name + Variants.values[1].name
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = Variants.valueStr
|
||||
+6
@@ -939,6 +939,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/builtinsProperties/throwable.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("valuesInsideEnum.kt")
|
||||
public void testValuesInsideEnum() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/builtinsProperties/valuesInsideEnum.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/casts")
|
||||
|
||||
@@ -145,7 +145,8 @@ public class DescriptorFactory {
|
||||
|
||||
KotlinType type = getBuiltIns(enumClass).getArrayType(Variance.INVARIANT, enumClass.getDefaultType());
|
||||
|
||||
PropertyGetterDescriptorImpl getter = createDefaultGetter(values, Annotations.Companion.getEMPTY());
|
||||
PropertyGetterDescriptorImpl getter = createGetter(
|
||||
values, Annotations.Companion.getEMPTY(), /* isDefault = */ false, /* isExternal = */ false);
|
||||
|
||||
values.initialize(getter, null);
|
||||
getter.initialize(type);
|
||||
|
||||
Reference in New Issue
Block a user