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