Moved and renamed DescriptorUtils.getInnerClasses
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -35,8 +35,8 @@ import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.*;
|
||||
@@ -237,4 +237,18 @@ public class CodegenUtil {
|
||||
private static boolean rawTypeMatches(JetType type, ClassDescriptor classDescriptor) {
|
||||
return type.getConstructor().getDeclarationDescriptor().getOriginal() == classDescriptor.getOriginal();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static Collection<ClassDescriptor> getInnerClassesAndObjects(ClassDescriptor classDescriptor) {
|
||||
JetScope innerClassesScope = classDescriptor.getUnsubstitutedInnerClassesScope();
|
||||
Collection<DeclarationDescriptor> inners = innerClassesScope.getAllDescriptors();
|
||||
for (DeclarationDescriptor inner : inners) {
|
||||
assert inner instanceof ClassDescriptor
|
||||
: "Not a class in inner classes scope of " + classDescriptor + ": " + inner;
|
||||
}
|
||||
return new ImmutableList.Builder<ClassDescriptor>()
|
||||
.addAll((Collection) inners)
|
||||
.addAll(innerClassesScope.getObjectDescriptors())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.OverridingUtil;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
@@ -191,7 +190,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
// Inner enums are moved by frontend to a class object of outer class, but we want them to be inner for the outer class itself
|
||||
// (to avoid publicly visible names like A$ClassObject$$B), so they are handled specially in this method
|
||||
|
||||
for (ClassDescriptor innerClass : DescriptorUtils.getInnerClasses(descriptor)) {
|
||||
for (ClassDescriptor innerClass : getInnerClassesAndObjects(descriptor)) {
|
||||
// If it's an inner enum inside a class object, don't write it
|
||||
// (instead write it to inner classes of this class object's containing class)
|
||||
if (!isEnumMovedToClassObject(innerClass)) {
|
||||
@@ -202,7 +201,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
ClassDescriptor classObjectDescriptor = descriptor.getClassObjectDescriptor();
|
||||
if (classObjectDescriptor != null) {
|
||||
// Process all enums here which were moved to our class object
|
||||
for (ClassDescriptor innerClass : DescriptorUtils.getInnerClasses(classObjectDescriptor)) {
|
||||
for (ClassDescriptor innerClass : getInnerClassesAndObjects(classObjectDescriptor)) {
|
||||
if (isEnumMovedToClassObject(innerClass)) {
|
||||
writeInnerClass(innerClass, true);
|
||||
}
|
||||
|
||||
@@ -365,18 +365,4 @@ public class DescriptorUtils {
|
||||
+ (classifier == null ? "null" : classifier.getClass());
|
||||
return (ClassDescriptor) classifier;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Collection<ClassDescriptor> getInnerClasses(ClassDescriptor classDescriptor) {
|
||||
JetScope innerClassesScope = classDescriptor.getUnsubstitutedInnerClassesScope();
|
||||
Collection<DeclarationDescriptor> inners = innerClassesScope.getAllDescriptors();
|
||||
for (DeclarationDescriptor inner : inners) {
|
||||
assert inner instanceof ClassDescriptor
|
||||
: "Not a class in inner classes scope of " + classDescriptor + ": " + inner;
|
||||
}
|
||||
return new ImmutableList.Builder<ClassDescriptor>()
|
||||
.addAll((Collection) inners)
|
||||
.addAll(innerClassesScope.getObjectDescriptors())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user