Kapt+JVM_IR: do not generate nested enum as final
#KT-54187 Fixed
This commit is contained in:
committed by
Space Team
parent
766a51069c
commit
c813e03c1e
+6
-6
@@ -654,17 +654,17 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getClassAccessFlags(clazz: ClassNode, descriptor: DeclarationDescriptor, isInner: Boolean, isNested: Boolean): Int {
|
private fun getClassAccessFlags(clazz: ClassNode, descriptor: DeclarationDescriptor, isInner: Boolean, isNested: Boolean): Int {
|
||||||
if ((descriptor.containingDeclaration as? ClassDescriptor)?.kind == ClassKind.INTERFACE) {
|
|
||||||
// Classes inside interfaces should always be public and static.
|
|
||||||
// See com.sun.tools.javac.comp.Enter.visitClassDef for more information.
|
|
||||||
return (clazz.access or Opcodes.ACC_PUBLIC or Opcodes.ACC_STATIC) and
|
|
||||||
Opcodes.ACC_PRIVATE.inv() and Opcodes.ACC_PROTECTED.inv() // Remove private and protected modifiers
|
|
||||||
}
|
|
||||||
var access = clazz.access
|
var access = clazz.access
|
||||||
if ((descriptor as? ClassDescriptor)?.kind == ClassKind.ENUM_CLASS) {
|
if ((descriptor as? ClassDescriptor)?.kind == ClassKind.ENUM_CLASS) {
|
||||||
// Enums are final in the bytecode, but "final enum" is not allowed in Java.
|
// Enums are final in the bytecode, but "final enum" is not allowed in Java.
|
||||||
access = access and Opcodes.ACC_FINAL.inv()
|
access = access and Opcodes.ACC_FINAL.inv()
|
||||||
}
|
}
|
||||||
|
if ((descriptor.containingDeclaration as? ClassDescriptor)?.kind == ClassKind.INTERFACE) {
|
||||||
|
// Classes inside interfaces should always be public and static.
|
||||||
|
// See com.sun.tools.javac.comp.Enter.visitClassDef for more information.
|
||||||
|
return (access or Opcodes.ACC_PUBLIC or Opcodes.ACC_STATIC) and
|
||||||
|
Opcodes.ACC_PRIVATE.inv() and Opcodes.ACC_PROTECTED.inv() // Remove private and protected modifiers
|
||||||
|
}
|
||||||
if (!isInner && isNested) {
|
if (!isInner && isNested) {
|
||||||
access = access or Opcodes.ACC_STATIC
|
access = access or Opcodes.ACC_STATIC
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,3 +21,7 @@ enum class Nested1 {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface I {
|
||||||
|
enum class Nested { WHITE }
|
||||||
|
}
|
||||||
|
|||||||
@@ -63,6 +63,23 @@ public enum Enum2 {
|
|||||||
////////////////////
|
////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
import java.lang.System;
|
||||||
|
|
||||||
|
@kotlin.Metadata()
|
||||||
|
public abstract interface I {
|
||||||
|
|
||||||
|
@kotlin.Metadata()
|
||||||
|
public static enum Nested {
|
||||||
|
/*public static final*/ WHITE /* = new Nested() */;
|
||||||
|
|
||||||
|
Nested() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////
|
||||||
|
|
||||||
|
|
||||||
import java.lang.System;
|
import java.lang.System;
|
||||||
|
|
||||||
@kotlin.Metadata()
|
@kotlin.Metadata()
|
||||||
|
|||||||
Reference in New Issue
Block a user