Kapt: never generate enums as final

Behavior differs between JVM and JVM_IR backends here because in JVM,
the class descriptor comes from the frontend, and its modality for enum
is never final. For JVM IR, the class descriptor is based on IrClass,
whose modality is sometimes final for enum, presumably because it's
easier for backends (see `ClassGenerator.getEffectiveModality`).

 #KT-49682
This commit is contained in:
Alexander Udalov
2021-12-16 00:19:07 +01:00
parent fc2c0eea27
commit b3820564b0
8 changed files with 82 additions and 20 deletions
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class E {
X {
override fun a() {}
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class Enum1 {
BLACK, WHITE
}
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JVM_IR
interface Context
enum class Result {
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JVM_IR
enum class Color {
BLACK, `WHI-TE`
}
@@ -7,5 +5,5 @@ enum class Color {
@Anno(Color.`WHI-TE`)
annotation class Anno(val color: Color)
// EXPECTED_ERROR(kotlin:7:1) an enum annotation value must be an enum constant
// EXPECTED_ERROR(kotlin:5:1) an enum annotation value must be an enum constant
// EXPECTED_ERROR(other:-1:-1) 'WHI-TE' is an invalid Java enum value name
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JVM_IR
class `:)` {
lateinit val f: String
}
@@ -0,0 +1,63 @@
import java.lang.System;
@kotlin.Metadata()
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
public abstract @interface Anno {
public abstract StrangeEnum size();
public abstract java.lang.String name();
}
////////////////////
import java.lang.System;
@kotlin.Metadata()
public enum StrangeEnum {
/*public static final*/ InvalidFieldName /* = new StrangeEnum() */;
@org.jetbrains.annotations.NotNull()
private final java.lang.String size = null;
StrangeEnum(java.lang.String size) {
}
@org.jetbrains.annotations.NotNull()
public final java.lang.String getSize() {
return null;
}
}
////////////////////
import java.lang.System;
@kotlin.Metadata()
public final class Test {
public final java.lang.String simpleName = null;
public Test() {
super();
}
@org.jetbrains.annotations.NotNull()
public final java.lang.String getSimpleName() {
return null;
}
public final void simpleFun() {
}
@Anno(size = StrangeEnum.InvalidFieldName, name = "Woofwoof")
public final void simpleFun2(@org.jetbrains.annotations.NotNull()
java.lang.String a, @org.jetbrains.annotations.NotNull()
java.lang.String b) {
}
public final void strangeFun4(@org.jetbrains.annotations.NotNull()
java.lang.String a, @org.jetbrains.annotations.NotNull()
java.lang.String p1_949560896) {
}
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// STRIP_METADATA
interface Context