Remove dependency of "descriptors" on Lists

Also insert a sensible starting capacity almost everywhere
This commit is contained in:
Alexander Udalov
2014-08-14 15:13:41 +04:00
parent aff7619206
commit 9bc7d27fe1
18 changed files with 92 additions and 84 deletions
@@ -16,13 +16,13 @@
package org.jetbrains.jet.lang.descriptors.impl;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.PackageFragmentDescriptor;
import org.jetbrains.jet.lang.descriptors.PackageFragmentProvider;
import org.jetbrains.jet.lang.resolve.name.FqName;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
@@ -38,10 +38,11 @@ public class CompositePackageFragmentProvider implements PackageFragmentProvider
@NotNull
@Override
public List<PackageFragmentDescriptor> getPackageFragments(@NotNull FqName fqName) {
List<PackageFragmentDescriptor> result = Lists.newArrayList();
ArrayList<PackageFragmentDescriptor> result = new ArrayList<PackageFragmentDescriptor>();
for (PackageFragmentProvider provider : providers) {
result.addAll(provider.getPackageFragments(fqName));
}
result.trimToSize();
return result;
}
@@ -16,7 +16,6 @@
package org.jetbrains.jet.lang.descriptors.impl;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -69,8 +68,9 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
@Nullable JetType unsubstitutedReturnType,
@Nullable Modality modality,
@NotNull Visibility visibility) {
this.typeParameters = Lists.newArrayList(typeParameters);
@NotNull Visibility visibility
) {
this.typeParameters = new ArrayList<TypeParameterDescriptor>(typeParameters);
this.unsubstitutedValueParameters = unsubstitutedValueParameters;
this.unsubstitutedReturnType = unsubstitutedReturnType;
this.modality = modality;
@@ -202,8 +202,11 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
) {
FunctionDescriptorImpl substitutedDescriptor = createSubstitutedCopy(newOwner, original, kind);
List<TypeParameterDescriptor> substitutedTypeParameters = Lists.newArrayList();
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(getTypeParameters(), originalSubstitutor, substitutedDescriptor, substitutedTypeParameters);
List<TypeParameterDescriptor> originalTypeParameters = getTypeParameters();
List<TypeParameterDescriptor> substitutedTypeParameters = new ArrayList<TypeParameterDescriptor>(originalTypeParameters.size());
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(
originalTypeParameters, originalSubstitutor, substitutedDescriptor, substitutedTypeParameters
);
JetType substitutedReceiverParameterType = null;
if (receiverParameter != null) {
@@ -16,7 +16,6 @@
package org.jetbrains.jet.lang.descriptors.impl;
import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
@@ -26,17 +25,16 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.SubstitutingScope;
import org.jetbrains.jet.lang.types.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class LazySubstitutingClassDescriptor implements ClassDescriptor {
private final ClassDescriptor original;
private final TypeSubstitutor originalSubstitutor;
private TypeSubstitutor newSubstitutor;
private List<TypeParameterDescriptor> typeParameters;
private TypeConstructor typeConstructor;
private JetType superclassType;
public LazySubstitutingClassDescriptor(ClassDescriptor descriptor, TypeSubstitutor substitutor) {
this.original = descriptor;
@@ -49,8 +47,11 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
newSubstitutor = originalSubstitutor;
}
else {
typeParameters = Lists.newArrayList();
newSubstitutor = DescriptorSubstitutor.substituteTypeParameters(original.getTypeConstructor().getParameters(), originalSubstitutor, this, typeParameters);
List<TypeParameterDescriptor> originalTypeParameters = original.getTypeConstructor().getParameters();
typeParameters = new ArrayList<TypeParameterDescriptor>(originalTypeParameters.size());
newSubstitutor = DescriptorSubstitutor.substituteTypeParameters(
originalTypeParameters, originalSubstitutor, this, typeParameters
);
}
}
return newSubstitutor;
@@ -67,8 +68,9 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
if (typeConstructor == null) {
TypeSubstitutor substitutor = getSubstitutor();
Collection<JetType> supertypes = Lists.newArrayList();
for (JetType supertype : originalTypeConstructor.getSupertypes()) {
Collection<JetType> originalSupertypes = originalTypeConstructor.getSupertypes();
Collection<JetType> supertypes = new ArrayList<JetType>(originalSupertypes.size());
for (JetType supertype : originalSupertypes) {
supertypes.add(substitutor.substitute(supertype, Variance.INVARIANT));
}
@@ -110,11 +112,12 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
@NotNull
@Override
public Collection<ConstructorDescriptor> getConstructors() {
Collection<ConstructorDescriptor> r = Lists.newArrayList();
for (ConstructorDescriptor constructor : original.getConstructors()) {
r.add((ConstructorDescriptor) constructor.substitute(getSubstitutor()));
Collection<ConstructorDescriptor> originalConstructors = original.getConstructors();
Collection<ConstructorDescriptor> result = new ArrayList<ConstructorDescriptor>(originalConstructors.size());
for (ConstructorDescriptor constructor : originalConstructors) {
result.add((ConstructorDescriptor) constructor.substitute(getSubstitutor()));
}
return r;
return result;
}
@NotNull
@@ -16,7 +16,6 @@
package org.jetbrains.jet.lang.descriptors.impl;
import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
@@ -26,6 +25,7 @@ import org.jetbrains.jet.lang.resolve.scopes.ChainedScope;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.TypeSubstitutor;
import java.util.ArrayList;
import java.util.List;
public class PackageViewDescriptorImpl extends DeclarationDescriptorImpl implements PackageViewDescriptor {
@@ -42,7 +42,7 @@ public class PackageViewDescriptorImpl extends DeclarationDescriptorImpl impleme
this.module = module;
this.fqName = fqName;
List<JetScope> scopes = Lists.newArrayList();
List<JetScope> scopes = new ArrayList<JetScope>(fragments.size() + 1);
assert !fragments.isEmpty() : fqName + " in " + module;
for (PackageFragmentDescriptor fragment : fragments) {
scopes.add(fragment.getMemberScope());
@@ -16,7 +16,6 @@
package org.jetbrains.jet.lang.descriptors.impl;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -31,6 +30,7 @@ import org.jetbrains.jet.lang.types.TypeSubstitutor;
import org.jetbrains.jet.lang.types.Variance;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -102,7 +102,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr
) {
setOutType(outType);
this.typeParameters = Lists.newArrayList(typeParameters);
this.typeParameters = new ArrayList<TypeParameterDescriptor>(typeParameters);
this.receiverParameter = receiverParameter;
this.expectedThisObject = expectedThisObject;
@@ -182,14 +182,14 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr
@Override
@NotNull
public List<PropertyAccessorDescriptor> getAccessors() {
List<PropertyAccessorDescriptor> r = Lists.newArrayListWithCapacity(2);
List<PropertyAccessorDescriptor> result = new ArrayList<PropertyAccessorDescriptor>(2);
if (getter != null) {
r.add(getter);
result.add(getter);
}
if (setter != null) {
r.add(setter);
result.add(setter);
}
return r;
return result;
}
@Override
@@ -212,8 +212,11 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr
) {
PropertyDescriptorImpl substitutedDescriptor = createSubstitutedCopy(newOwner, newModality, newVisibility, original, kind);
List<TypeParameterDescriptor> substitutedTypeParameters = Lists.newArrayList();
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(getTypeParameters(), originalSubstitutor, substitutedDescriptor, substitutedTypeParameters);
List<TypeParameterDescriptor> originalTypeParameters = getTypeParameters();
List<TypeParameterDescriptor> substitutedTypeParameters = new ArrayList<TypeParameterDescriptor>(originalTypeParameters.size());
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(
originalTypeParameters, originalSubstitutor, substitutedDescriptor, substitutedTypeParameters
);
JetType originalOutType = getType();
JetType outType = substitutor.substitute(originalOutType, Variance.OUT_VARIANCE);
@@ -16,7 +16,6 @@
package org.jetbrains.jet.lang.descriptors.impl;
import com.google.common.collect.Lists;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,6 +26,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.JetScopeImpl;
import org.jetbrains.jet.utils.Printer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -53,8 +53,9 @@ public class SubpackagesScope extends JetScopeImpl {
@NotNull
@Override
public Collection<DeclarationDescriptor> getAllDescriptors() {
List<DeclarationDescriptor> result = Lists.newArrayList();
for (FqName subFqName : packageView.getModule().getPackageFragmentProvider().getSubPackagesOf(packageView.getFqName())) {
Collection<FqName> subFqNames = packageView.getModule().getPackageFragmentProvider().getSubPackagesOf(packageView.getFqName());
List<DeclarationDescriptor> result = new ArrayList<DeclarationDescriptor>(subFqNames.size());
for (FqName subFqName : subFqNames) {
ContainerUtil.addIfNotNull(result, getPackage(subFqName.shortName()));
}
return result;
@@ -16,7 +16,6 @@
package org.jetbrains.jet.lang.resolve;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.intellij.util.containers.ContainerUtil;
import kotlin.Function1;
@@ -268,7 +267,7 @@ public class OverridingUtil {
@NotNull ClassDescriptor current,
@NotNull DescriptorSink sink
) {
Collection<CallableMemberDescriptor> bound = Lists.newArrayList();
Collection<CallableMemberDescriptor> bound = new ArrayList<CallableMemberDescriptor>(descriptorsFromSuper.size());
for (CallableMemberDescriptor fromSupertype : descriptorsFromSuper) {
OverrideCompatibilityInfo.Result result = DEFAULT.isOverridableBy(fromSupertype, fromCurrent).getResult();
@@ -392,7 +391,7 @@ public class OverridingUtil {
@NotNull Queue<CallableMemberDescriptor> extractFrom,
@NotNull DescriptorSink sink
) {
Collection<CallableMemberDescriptor> overridable = Lists.newArrayList();
Collection<CallableMemberDescriptor> overridable = new ArrayList<CallableMemberDescriptor>();
overridable.add(overrider);
for (Iterator<CallableMemberDescriptor> iterator = extractFrom.iterator(); iterator.hasNext(); ) {
CallableMemberDescriptor candidate = iterator.next();
@@ -16,12 +16,12 @@
package org.jetbrains.jet.lang.resolve.calls.inference;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import kotlin.Function1;
import kotlin.KotlinPackage;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
@@ -75,7 +75,7 @@ public class ConstraintPosition {
}
public static ConstraintPosition getCompoundConstraintPosition(ConstraintPosition... positions) {
return new CompoundConstraintPosition(Lists.newArrayList(positions));
return new CompoundConstraintPosition(Arrays.asList(positions));
}
private final String debugName;
@@ -16,7 +16,6 @@
package org.jetbrains.jet.lang.resolve.calls.inference;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import kotlin.Function1;
@@ -31,7 +30,7 @@ import org.jetbrains.jet.lang.types.checker.TypingConstraints;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.utils.UtilsPackage;
import java.util.Collection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -444,7 +443,7 @@ public class ConstraintSystemImpl implements ConstraintSystem {
TypeBoundsImpl typeBounds = entry.getValue();
for (JetType declaredUpperBound : typeParameterDescriptor.getUpperBounds()) {
//todo order matters here
Collection<Bound> bounds = Lists.newArrayList(typeBounds.getBounds());
Collection<Bound> bounds = new ArrayList<Bound>(typeBounds.getBounds());
for (Bound bound : bounds) {
if (bound.kind == LOWER_BOUND || bound.kind == EXACT_BOUND) {
ConstraintPosition position = ConstraintPosition.getCompoundConstraintPosition(
@@ -514,10 +513,10 @@ public class ConstraintSystemImpl implements ConstraintSystem {
List<TypeProjection> typeArguments = functionType.getArguments();
assert !typeArguments.isEmpty();
List<JetType> arguments = Lists.newArrayList();
// excluding the last type argument of the function type, which is the return type
int index = 0;
int lastIndex = typeArguments.size() - 1;
List<JetType> arguments = new ArrayList<JetType>(lastIndex);
for (TypeProjection typeArgument : typeArguments) {
if (index < lastIndex) {
arguments.add(typeArgument.getType());
@@ -16,7 +16,6 @@
package org.jetbrains.jet.lang.resolve.calls.inference;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.intellij.util.containers.ContainerUtil;
import kotlin.Function1;
@@ -28,10 +27,7 @@ import org.jetbrains.jet.lang.resolve.constants.IntegerValueTypeConstructor;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.*;
import static org.jetbrains.jet.lang.resolve.calls.inference.TypeBounds.BoundKind.LOWER_BOUND;
@@ -191,7 +187,8 @@ public class TypeBoundsImpl implements TypeBounds {
if (superTypeOfLowerBounds != null && superTypeOfNumberLowerBounds != null) {
JetType superTypeOfAllLowerBounds = CommonSupertypes.commonSupertypeForNonDenotableTypes(
Lists.newArrayList(superTypeOfLowerBounds, superTypeOfNumberLowerBounds));
Arrays.asList(superTypeOfLowerBounds, superTypeOfNumberLowerBounds)
);
if (tryPossibleAnswer(superTypeOfAllLowerBounds)) {
return Collections.singleton(superTypeOfAllLowerBounds);
}
@@ -16,7 +16,6 @@
package org.jetbrains.jet.lang.resolve.constants;
import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
@@ -26,13 +25,14 @@ import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeConstructor;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class IntegerValueTypeConstructor implements TypeConstructor {
private final long value;
private final Collection<JetType> supertypes = Lists.newArrayList();
private final Collection<JetType> supertypes = new ArrayList<JetType>(4);
public IntegerValueTypeConstructor(long value) {
// order of types matters
@@ -16,10 +16,10 @@
package org.jetbrains.jet.lang.resolve.name;
import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.utils.UtilsPackage;
import java.util.ArrayList;
import java.util.List;
public final class FqName extends FqNameBase {
@@ -116,7 +116,7 @@ public final class FqName extends FqNameBase {
@NotNull
public List<FqName> path() {
final List<FqName> path = Lists.newArrayList();
final List<FqName> path = new ArrayList<FqName>();
path.add(ROOT);
fqName.walk(new FqNameUnsafe.WalkCallback() {
@Override
@@ -16,11 +16,11 @@
package org.jetbrains.jet.lang.resolve.name;
import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.utils.UtilsPackage;
import java.util.ArrayList;
import java.util.List;
/**
@@ -170,7 +170,7 @@ public final class FqNameUnsafe extends FqNameBase {
@NotNull
public List<FqNameUnsafe> path() {
final List<FqNameUnsafe> path = Lists.newArrayList();
final List<FqNameUnsafe> path = new ArrayList<FqNameUnsafe>();
path.add(FqName.ROOT.toUnsafe());
walk(new WalkCallback() {
@Override
@@ -184,7 +184,7 @@ public final class FqNameUnsafe extends FqNameBase {
@Override
@NotNull
public List<Name> pathSegments() {
final List<Name> path = Lists.newArrayList();
final List<Name> path = new ArrayList<Name>();
walk(new WalkCallback() {
@Override
public void segment(@NotNull Name shortName, @NotNull FqNameUnsafe fqName) {
@@ -16,7 +16,6 @@
package org.jetbrains.jet.lang.resolve.scopes;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.TestOnly;
@@ -24,7 +23,10 @@ import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.utils.Printer;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import static org.jetbrains.jet.lang.resolve.scopes.JetScopeSelectorUtil.*;
@@ -73,10 +75,12 @@ public class ChainedScope implements JetScope {
@Override
public List<ReceiverParameterDescriptor> getImplicitReceiversHierarchy() {
if (implicitReceiverHierarchy == null) {
implicitReceiverHierarchy = Lists.newArrayList();
ArrayList<ReceiverParameterDescriptor> result = new ArrayList<ReceiverParameterDescriptor>();
for (JetScope jetScope : scopeChain) {
implicitReceiverHierarchy.addAll(jetScope.getImplicitReceiversHierarchy());
result.addAll(jetScope.getImplicitReceiversHierarchy());
}
result.trimToSize();
implicitReceiverHierarchy = result;
}
return implicitReceiverHierarchy;
}
@@ -16,7 +16,6 @@
package org.jetbrains.jet.lang.types;
import com.google.common.collect.Lists;
import com.intellij.openapi.progress.ProcessCanceledException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -24,6 +23,7 @@ import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
import org.jetbrains.jet.lang.resolve.scopes.SubstitutingScope;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -192,9 +192,10 @@ public class TypeSubstitutor {
}
}
private List<TypeProjection> substituteTypeArguments(List<TypeParameterDescriptor> typeParameters, List<TypeProjection> typeArguments, int recursionDepth)
throws SubstitutionException {
List<TypeProjection> substitutedArguments = Lists.newArrayList();
private List<TypeProjection> substituteTypeArguments(
List<TypeParameterDescriptor> typeParameters, List<TypeProjection> typeArguments, int recursionDepth
) throws SubstitutionException {
List<TypeProjection> substitutedArguments = new ArrayList<TypeProjection>(typeParameters.size());
for (int i = 0; i < typeParameters.size(); i++) {
TypeParameterDescriptor typeParameter = typeParameters.get(i);
TypeProjection typeArgument = typeArguments.get(i);
@@ -16,7 +16,6 @@
package org.jetbrains.jet.lang.types;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import kotlin.Function1;
@@ -139,7 +138,7 @@ public class TypeUtils {
}
public static boolean isIntersectionEmpty(@NotNull JetType typeA, @NotNull JetType typeB) {
return intersect(JetTypeChecker.DEFAULT, Sets.newLinkedHashSet(Lists.newArrayList(typeA, typeB))) == null;
return intersect(JetTypeChecker.DEFAULT, Sets.newLinkedHashSet(Arrays.asList(typeA, typeB))) == null;
}
@Nullable
@@ -156,7 +155,7 @@ public class TypeUtils {
// made nullable is they all were nullable
boolean allNullable = true;
boolean nothingTypePresent = false;
List<JetType> nullabilityStripped = Lists.newArrayList();
List<JetType> nullabilityStripped = new ArrayList<JetType>(types.size());
for (JetType type : types) {
nothingTypePresent |= KotlinBuiltIns.getInstance().isNothingOrNullableNothing(type);
allNullable &= type.isNullable();
@@ -168,7 +167,7 @@ public class TypeUtils {
}
// Now we remove types that have subtypes in the list
List<JetType> resultingTypes = Lists.newArrayList();
List<JetType> resultingTypes = new ArrayList<JetType>();
outer:
for (JetType type : nullabilityStripped) {
if (!canHaveSubtypes(typeChecker, type)) {
@@ -372,21 +371,18 @@ public class TypeUtils {
return result;
}
private static void collectImmediateSupertypes(@NotNull JetType type, @NotNull Collection<JetType> result) {
@NotNull
public static List<JetType> getImmediateSupertypes(@NotNull JetType type) {
boolean isNullable = type.isNullable();
TypeSubstitutor substitutor = TypeSubstitutor.create(type);
for (JetType supertype : type.getConstructor().getSupertypes()) {
Collection<JetType> originalSupertypes = type.getConstructor().getSupertypes();
List<JetType> result = new ArrayList<JetType>(originalSupertypes.size());
for (JetType supertype : originalSupertypes) {
JetType substitutedType = substitutor.substitute(supertype, Variance.INVARIANT);
if (substitutedType != null) {
result.add(makeNullableIfNeeded(substitutedType, isNullable));
}
}
}
@NotNull
public static List<JetType> getImmediateSupertypes(@NotNull JetType type) {
List<JetType> result = Lists.newArrayList();
collectImmediateSupertypes(type, result);
return result;
}
@@ -617,8 +613,9 @@ public class TypeUtils {
@Override
public Iterable<JetType> getNeighbors(JetType current) {
TypeSubstitutor substitutor = TypeSubstitutor.create(current);
List<JetType> result = Lists.newArrayList();
for (JetType supertype : current.getConstructor().getSupertypes()) {
Collection<JetType> supertypes = current.getConstructor().getSupertypes();
List<JetType> result = new ArrayList<JetType>(supertypes.size());
for (JetType supertype : supertypes) {
if (visited.contains(supertype.getConstructor())) {
continue;
}
@@ -17,7 +17,6 @@
package org.jetbrains.jet.lang.types.lang;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import kotlin.KotlinPackage;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -783,13 +782,14 @@ public class KotlinBuiltIns {
@NotNull
public List<ValueParameterDescriptor> getValueParameters(@NotNull FunctionDescriptor functionDescriptor, @NotNull JetType type) {
assert isFunctionOrExtensionFunctionType(type);
List<ValueParameterDescriptor> valueParameters = Lists.newArrayList();
List<TypeProjection> parameterTypes = getParameterTypeProjectionsFromFunctionType(type);
List<ValueParameterDescriptor> valueParameters = new ArrayList<ValueParameterDescriptor>(parameterTypes.size());
for (int i = 0; i < parameterTypes.size(); i++) {
TypeProjection parameterType = parameterTypes.get(i);
ValueParameterDescriptorImpl valueParameterDescriptor = new ValueParameterDescriptorImpl(
functionDescriptor, null, i, Annotations.EMPTY,
Name.identifier("p" + (i + 1)), parameterType.getType(), false, null, SourceElement.NO_SOURCE);
Name.identifier("p" + (i + 1)), parameterType.getType(), false, null, SourceElement.NO_SOURCE
);
valueParameters.add(valueParameterDescriptor);
}
return valueParameters;
@@ -808,7 +808,7 @@ public class KotlinBuiltIns {
List<TypeProjection> arguments = type.getArguments();
int first = isExtensionFunctionType(type) ? 1 : 0;
int last = arguments.size() - 2;
List<TypeProjection> parameterTypes = Lists.newArrayList();
List<TypeProjection> parameterTypes = new ArrayList<TypeProjection>(last - first + 1);
for (int i = first; i <= last; i++) {
parameterTypes.add(arguments.get(i));
}
@@ -16,7 +16,6 @@
package org.jetbrains.jet.renderer;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import kotlin.Function1;
import kotlin.KotlinPackage;
@@ -248,7 +247,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
return klass.getTypeConstructor().toString();
}
if (shortNames) {
List<Name> qualifiedNameElements = Lists.newArrayList();
List<Name> qualifiedNameElements = new ArrayList<Name>();
// for nested classes qualified name should be used
DeclarationDescriptor current = klass;
@@ -415,8 +414,9 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
@NotNull
private List<String> renderAndSortAnnotationArguments(@NotNull AnnotationDescriptor descriptor) {
List<String> resultList = Lists.newArrayList();
for (Map.Entry<ValueParameterDescriptor, CompileTimeConstant<?>> entry : descriptor.getAllValueArguments().entrySet()) {
Set<Map.Entry<ValueParameterDescriptor, CompileTimeConstant<?>>> valueArguments = descriptor.getAllValueArguments().entrySet();
List<String> resultList = new ArrayList<String>(valueArguments.size());
for (Map.Entry<ValueParameterDescriptor, CompileTimeConstant<?>> entry : valueArguments) {
CompileTimeConstant<?> value = entry.getValue();
String typeSuffix = ": " + renderType(value.getType(KotlinBuiltIns.getInstance()));
resultList.add(entry.getKey().getName().asString() + " = " + renderConstant(value) + typeSuffix);
@@ -665,7 +665,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
private void renderWhereSuffix(@NotNull List<TypeParameterDescriptor> typeParameters, @NotNull StringBuilder builder) {
if (withoutTypeParameters) return;
List<String> upperBoundStrings = Lists.newArrayList();
List<String> upperBoundStrings = new ArrayList<String>(0);
for (TypeParameterDescriptor typeParameter : typeParameters) {
if (typeParameter.getUpperBounds().size() > 1) {