diff --git a/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt b/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt index 0d88e717dec..ed159015378 100644 --- a/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt +++ b/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt @@ -654,17 +654,17 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati } 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 if ((descriptor as? ClassDescriptor)?.kind == ClassKind.ENUM_CLASS) { // Enums are final in the bytecode, but "final enum" is not allowed in Java. 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) { access = access or Opcodes.ACC_STATIC } diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/enums.kt b/plugins/kapt3/kapt3-compiler/testData/converter/enums.kt index 494cb4c3b0f..70cccd4c6dd 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/enums.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/enums.kt @@ -21,3 +21,7 @@ enum class Nested1 { } }; } + +interface I { + enum class Nested { WHITE } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/enums.txt b/plugins/kapt3/kapt3-compiler/testData/converter/enums.txt index 2ce210299ff..af48064ad24 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/enums.txt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/enums.txt @@ -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; @kotlin.Metadata()