Properly compute STATIC for light classes
This commit is contained in:
@@ -78,7 +78,7 @@ public abstract class ClassBuilder {
|
||||
String superName,
|
||||
String[] interfaces
|
||||
) {
|
||||
getVisitor().visit(version, access & ~Opcodes.ACC_STATIC, name, signature, superName, interfaces);
|
||||
getVisitor().visit(version, access, name, signature, superName, interfaces);
|
||||
}
|
||||
|
||||
public void visitSource(String name, @Nullable String debug) {
|
||||
|
||||
@@ -21,10 +21,7 @@ import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.asm4.AnnotationVisitor;
|
||||
import org.jetbrains.asm4.Label;
|
||||
import org.jetbrains.asm4.MethodVisitor;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.*;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.asm4.commons.Method;
|
||||
import org.jetbrains.jet.codegen.binding.CalculatedClosure;
|
||||
@@ -119,6 +116,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (!jetClass.hasModifier(JetTokens.OPEN_KEYWORD) && !isAbstract) {
|
||||
isFinal = true;
|
||||
}
|
||||
isStatic = !jetClass.isInner();
|
||||
}
|
||||
else {
|
||||
isStatic = myClass.getParent() instanceof JetClassObject;
|
||||
@@ -133,6 +131,10 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
// without knowing whether these classes are inner or not (see ClassStubBuilder.EMPTY_STRATEGY)
|
||||
// Thus we must write full accessibility flags on inner classes in this mode
|
||||
access |= getVisibilityAccessFlag(descriptor);
|
||||
// Same for STATIC
|
||||
if (isStatic) {
|
||||
access |= ACC_STATIC;
|
||||
}
|
||||
}
|
||||
else {
|
||||
access |= getVisibilityAccessFlagForClass(descriptor);
|
||||
@@ -149,9 +151,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (isFinal) {
|
||||
access |= ACC_FINAL;
|
||||
}
|
||||
if (isStatic) {
|
||||
access |= ACC_STATIC;
|
||||
}
|
||||
if (isAnnotation) {
|
||||
access |= ACC_ANNOTATION;
|
||||
}
|
||||
|
||||
+3
-4
@@ -313,10 +313,9 @@ public class KotlinLightClassForExplicitDeclaration extends AbstractLightClass i
|
||||
psiModifiers.add(PsiModifier.FINAL);
|
||||
}
|
||||
|
||||
// TODO: STATIC
|
||||
//if (nestedClass && jetModifierList.hasModifier(INNER_KEYWORD)) {
|
||||
// psiModifiers.add(PsiModifier.STATIC);
|
||||
//}
|
||||
if (nestedClass && !classOrObject.hasModifier(INNER_KEYWORD)) {
|
||||
psiModifiers.add(PsiModifier.STATIC);
|
||||
}
|
||||
|
||||
return psiModifiers.toArray(new String[psiModifiers.size()]);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ class Outer {
|
||||
protected class Protected
|
||||
private class Private
|
||||
internal class Internal
|
||||
|
||||
inner class Inner
|
||||
}
|
||||
|
||||
// Modality
|
||||
|
||||
@@ -136,22 +136,26 @@ public class KotlinLightClassCoherenceTest extends KotlinAsJavaTestBase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInnerPublic() throws Exception {
|
||||
public void testNestedPublic() throws Exception {
|
||||
doTest("test.Outer.Public");
|
||||
}
|
||||
|
||||
public void testInnerProtected() throws Exception {
|
||||
public void testNestedProtected() throws Exception {
|
||||
doTest("test.Outer.Protected");
|
||||
}
|
||||
|
||||
public void testInnerInternal() throws Exception {
|
||||
public void testNestedInternal() throws Exception {
|
||||
doTest("test.Outer.Internal");
|
||||
}
|
||||
|
||||
public void testInnerPrivate() throws Exception {
|
||||
public void testNestedPrivate() throws Exception {
|
||||
doTest("test.Outer.Private");
|
||||
}
|
||||
|
||||
public void testInner() throws Exception {
|
||||
doTest("test.Outer.Inner");
|
||||
}
|
||||
|
||||
public void testAbstract() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@@ -60,10 +60,12 @@ public abstract class KotlinLightClassTest extends KotlinAsJavaTestBase {
|
||||
}
|
||||
|
||||
public void testNestedVisibilities() {
|
||||
checkModifiers("test.Outer.Public", PUBLIC, FINAL, INNER);
|
||||
checkModifiers("test.Outer.Protected", PROTECTED, FINAL, INNER);
|
||||
checkModifiers("test.Outer.Internal", PUBLIC, FINAL, INNER);
|
||||
checkModifiers("test.Outer.Private", PRIVATE, FINAL, INNER);
|
||||
checkModifiers("test.Outer.Public", PUBLIC, STATIC, FINAL, NESTED);
|
||||
checkModifiers("test.Outer.Protected", PROTECTED, STATIC, FINAL, NESTED);
|
||||
checkModifiers("test.Outer.Internal", PUBLIC, STATIC, FINAL, NESTED);
|
||||
checkModifiers("test.Outer.Private", PRIVATE, STATIC, FINAL, NESTED);
|
||||
|
||||
checkModifiers("test.Outer.Inner", PUBLIC, FINAL, NESTED);
|
||||
}
|
||||
public void testModalities() {
|
||||
checkModifiers("test.Abstract", PUBLIC, ABSTRACT);
|
||||
@@ -224,7 +226,7 @@ public abstract class KotlinLightClassTest extends KotlinAsJavaTestBase {
|
||||
return psiClass.isDeprecated();
|
||||
}
|
||||
},
|
||||
INNER {
|
||||
NESTED {
|
||||
@Override
|
||||
public boolean present(@NotNull PsiClass psiClass) {
|
||||
return psiClass.getContainingClass() != null;
|
||||
|
||||
Reference in New Issue
Block a user