Fix abstract nested class in enums in JVM back-end

It caused InstantiationError because the enum had an incorrect ACC_ABSTRACT
flag
This commit is contained in:
Alexander Udalov
2014-04-16 20:12:32 +04:00
parent 129b643898
commit f7235e9d82
3 changed files with 27 additions and 10 deletions
@@ -21,6 +21,9 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Stack;
import jet.runtime.typeinfo.JetValueParameter;
import kotlin.Function1;
import kotlin.KotlinPackage;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.codegen.binding.CalculatedClosure;
@@ -182,16 +185,15 @@ public class CodegenUtil {
}
public static boolean hasAbstractMembers(@NotNull ClassDescriptor classDescriptor) {
return ContainerUtil.exists(classDescriptor.getDefaultType().getMemberScope().getAllDescriptors(),
new Condition<DeclarationDescriptor>() {
@Override
public boolean value(DeclarationDescriptor declaration) {
if (!(declaration instanceof MemberDescriptor)) {
return false;
}
return ((MemberDescriptor) declaration).getModality() == ABSTRACT;
}
});
return KotlinPackage.any(classDescriptor.getDefaultType().getMemberScope().getAllDescriptors(),
new Function1<DeclarationDescriptor, Boolean>() {
@Override
public Boolean invoke(DeclarationDescriptor descriptor) {
return descriptor instanceof CallableMemberDescriptor &&
((CallableMemberDescriptor) descriptor).getModality() == ABSTRACT;
}
}
);
}
/**
@@ -0,0 +1,10 @@
enum class E {
abstract class Nested
ENTRY
}
fun box(): String {
E.ENTRY
return "OK"
}
@@ -2366,6 +2366,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest("compiler/testData/codegen/box/enum/abstractMethodInEnum.kt");
}
@TestMetadata("abstractNestedClass.kt")
public void testAbstractNestedClass() throws Exception {
doTest("compiler/testData/codegen/box/enum/abstractNestedClass.kt");
}
@TestMetadata("abstractmethod.kt")
public void testAbstractmethod() throws Exception {
doTest("compiler/testData/codegen/box/enum/abstractmethod.kt");