Kapt3: Nested class inside an interface should always be public and static (KT-15145)
This commit is contained in:
committed by
Yan Zhulanow
parent
d918015c30
commit
4667947315
+12
-3
@@ -135,9 +135,18 @@ class ClassFileToSourceStubConverter(
|
|||||||
val isNested = (descriptor as? ClassDescriptor)?.isNested ?: false
|
val isNested = (descriptor as? ClassDescriptor)?.isNested ?: false
|
||||||
val isInner = isNested && (descriptor as? ClassDescriptor)?.isInner ?: false
|
val isInner = isNested && (descriptor as? ClassDescriptor)?.isInner ?: false
|
||||||
|
|
||||||
val modifiers = convertModifiers(
|
val flags = when {
|
||||||
if (!isInner && isNested) (clazz.access or Opcodes.ACC_STATIC) else clazz.access,
|
(descriptor.containingDeclaration as? ClassDescriptor)?.kind == ClassKind.INTERFACE -> {
|
||||||
ElementKind.CLASS, packageFqName, clazz.visibleAnnotations, clazz.invisibleAnnotations)
|
// Classes inside interfaces should always be public and static.
|
||||||
|
// See com.sun.tools.javac.comp.Enter.visitClassDef for more information.
|
||||||
|
(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
|
||||||
|
}
|
||||||
|
!isInner && isNested -> clazz.access or Opcodes.ACC_STATIC
|
||||||
|
else -> clazz.access
|
||||||
|
}
|
||||||
|
|
||||||
|
val modifiers = convertModifiers(flags, ElementKind.CLASS, packageFqName, clazz.visibleAnnotations, clazz.invisibleAnnotations)
|
||||||
|
|
||||||
val isEnum = clazz.isEnum()
|
val isEnum = clazz.isEnum()
|
||||||
val isAnnotation = clazz.isAnnotation()
|
val isAnnotation = clazz.isAnnotation()
|
||||||
|
|||||||
+6
@@ -144,6 +144,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt15145.kt")
|
||||||
|
public void testKt15145() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/kt15145.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("mapEntry.kt")
|
@TestMetadata("mapEntry.kt")
|
||||||
public void testMapEntry() throws Exception {
|
public void testMapEntry() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/mapEntry.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/mapEntry.kt");
|
||||||
|
|||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
interface MyInterface {
|
||||||
|
fun someFun()
|
||||||
|
private class MyDefaultInferface()
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
public abstract interface MyInterface {
|
||||||
|
|
||||||
|
public abstract void someFun();
|
||||||
|
|
||||||
|
public static final class MyDefaultInferface {
|
||||||
|
|
||||||
|
public MyDefaultInferface() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user