Merge stored empty lists and sets to singe object
This commit is contained in:
+7
-6
@@ -39,6 +39,7 @@ import org.jetbrains.jet.storage.MemoizedFunctionToNotNull;
|
||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||
import org.jetbrains.jet.storage.StorageManager;
|
||||
import org.jetbrains.jet.utils.Printer;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -106,7 +107,7 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
|
||||
private List<ClassDescriptor> resolveClassDescriptor(@NotNull final Name name) {
|
||||
Collection<JetClassLikeInfo> classOrObjectDeclarations = declarationProvider.getClassOrObjectDeclarations(name);
|
||||
|
||||
return ContainerUtil.mapNotNull(classOrObjectDeclarations, new Function<JetClassLikeInfo, ClassDescriptor>() {
|
||||
return UtilsPackage.toReadOnlyList(ContainerUtil.mapNotNull(classOrObjectDeclarations, new Function<JetClassLikeInfo, ClassDescriptor>() {
|
||||
@Override
|
||||
public ClassDescriptor fun(JetClassLikeInfo classLikeInfo) {
|
||||
// SCRIPT: Creating a script class
|
||||
@@ -115,7 +116,7 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
|
||||
}
|
||||
return new LazyClassDescriptor(resolveSession, thisDescriptor, name, classLikeInfo);
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,7 +154,7 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
|
||||
|
||||
getNonDeclaredFunctions(name, result);
|
||||
|
||||
return result;
|
||||
return UtilsPackage.toReadOnlySet(result);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -189,7 +190,7 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
|
||||
|
||||
getNonDeclaredProperties(name, result);
|
||||
|
||||
return result;
|
||||
return UtilsPackage.toReadOnlySet(result);
|
||||
}
|
||||
|
||||
protected abstract void getNonDeclaredProperties(@NotNull Name name, @NotNull Set<VariableDescriptor> result);
|
||||
@@ -252,8 +253,8 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
|
||||
throw new IllegalArgumentException("Unsupported declaration kind: " + declaration);
|
||||
}
|
||||
}
|
||||
result.trimToSize();
|
||||
return result;
|
||||
|
||||
return UtilsPackage.toReadOnlyList(result);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+3
-3
@@ -36,6 +36,7 @@ import org.jetbrains.jet.lang.types.DeferredType;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.storage.NullableLazyValue;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -299,7 +300,7 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
|
||||
@Override
|
||||
@NotNull
|
||||
protected Collection<DeclarationDescriptor> computeExtraDescriptors() {
|
||||
ArrayList<DeclarationDescriptor> result = new ArrayList<DeclarationDescriptor>();
|
||||
List<DeclarationDescriptor> result = new ArrayList<DeclarationDescriptor>();
|
||||
for (JetType supertype : thisDescriptor.getTypeConstructor().getSupertypes()) {
|
||||
for (DeclarationDescriptor descriptor : supertype.getMemberScope().getAllDescriptors()) {
|
||||
if (descriptor instanceof FunctionDescriptor) {
|
||||
@@ -314,8 +315,7 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
|
||||
|
||||
addDataClassMethods(result);
|
||||
|
||||
result.trimToSize();
|
||||
return result;
|
||||
return UtilsPackage.toReadOnlyList(result);
|
||||
}
|
||||
|
||||
private void addDataClassMethods(@NotNull Collection<DeclarationDescriptor> result) {
|
||||
|
||||
+3
-2
@@ -30,6 +30,7 @@ import org.jetbrains.jet.lang.resolve.lazy.data.JetScriptInfo;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.declarations.ClassMemberDeclarationProvider;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
@@ -61,13 +62,13 @@ public class LazyScriptClassMemberScope extends LazyClassMemberScope {
|
||||
@NotNull
|
||||
@Override
|
||||
protected Collection<DeclarationDescriptor> computeExtraDescriptors() {
|
||||
return KotlinPackage.plus(
|
||||
return UtilsPackage.toReadOnlyList(KotlinPackage.plus(
|
||||
super.computeExtraDescriptors(),
|
||||
KotlinPackage.plus(
|
||||
getProperties(Name.identifier(ScriptDescriptor.LAST_EXPRESSION_VALUE_FIELD_NAME)),
|
||||
getPropertiesForScriptParameters()
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
private Collection<VariableDescriptor> getPropertiesForScriptParameters() {
|
||||
|
||||
Reference in New Issue
Block a user