Remove dependency of "descriptors" on Maps/Sets
This commit is contained in:
@@ -16,12 +16,13 @@
|
||||
|
||||
package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import kotlin.KotlinPackage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -108,7 +109,8 @@ public class Visibilities {
|
||||
}
|
||||
};
|
||||
|
||||
public static final Set<Visibility> INVISIBLE_FROM_OTHER_MODULES = Sets.newHashSet(PRIVATE, INTERNAL, LOCAL);
|
||||
public static final Set<Visibility> INVISIBLE_FROM_OTHER_MODULES =
|
||||
Collections.unmodifiableSet(KotlinPackage.setOf(PRIVATE, INTERNAL, LOCAL));
|
||||
|
||||
private Visibilities() {
|
||||
}
|
||||
@@ -132,13 +134,15 @@ public class Visibilities {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final Map<Visibility, Integer> ORDERED_VISIBILITIES = Maps.newHashMap();
|
||||
private static final Map<Visibility, Integer> ORDERED_VISIBILITIES;
|
||||
|
||||
static {
|
||||
ORDERED_VISIBILITIES.put(PRIVATE, 0);
|
||||
ORDERED_VISIBILITIES.put(INTERNAL, 1);
|
||||
ORDERED_VISIBILITIES.put(PROTECTED, 1);
|
||||
ORDERED_VISIBILITIES.put(PUBLIC, 2);
|
||||
Map<Visibility, Integer> visibilities = UtilsPackage.newHashMapWithExpectedSize(4);
|
||||
visibilities.put(PRIVATE, 0);
|
||||
visibilities.put(INTERNAL, 1);
|
||||
visibilities.put(PROTECTED, 1);
|
||||
visibilities.put(PUBLIC, 2);
|
||||
ORDERED_VISIBILITIES = Collections.unmodifiableMap(visibilities);
|
||||
}
|
||||
|
||||
/*package*/
|
||||
|
||||
+2
-6
@@ -16,16 +16,12 @@
|
||||
|
||||
package org.jetbrains.jet.lang.descriptors.impl;
|
||||
|
||||
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;
|
||||
import java.util.*;
|
||||
|
||||
public class CompositePackageFragmentProvider implements PackageFragmentProvider {
|
||||
// can be modified from outside
|
||||
@@ -49,7 +45,7 @@ public class CompositePackageFragmentProvider implements PackageFragmentProvider
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<FqName> getSubPackagesOf(@NotNull FqName fqName) {
|
||||
Set<FqName> result = Sets.newHashSet();
|
||||
Set<FqName> result = new HashSet<FqName>();
|
||||
for (PackageFragmentProvider provider : providers) {
|
||||
result.addAll(provider.getSubPackagesOf(fqName));
|
||||
}
|
||||
|
||||
+8
-10
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.descriptors.impl;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -30,20 +29,19 @@ import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRootImpl implements FunctionDescriptor {
|
||||
|
||||
protected List<TypeParameterDescriptor> typeParameters;
|
||||
protected List<ValueParameterDescriptor> unsubstitutedValueParameters;
|
||||
protected JetType unsubstitutedReturnType;
|
||||
private List<TypeParameterDescriptor> typeParameters;
|
||||
private List<ValueParameterDescriptor> unsubstitutedValueParameters;
|
||||
private JetType unsubstitutedReturnType;
|
||||
private ReceiverParameterDescriptor receiverParameter;
|
||||
protected ReceiverParameterDescriptor expectedThisObject;
|
||||
protected Modality modality;
|
||||
|
||||
protected Visibility visibility;
|
||||
protected final Set<FunctionDescriptor> overriddenFunctions = Sets.newLinkedHashSet(); // LinkedHashSet is essential here
|
||||
private ReceiverParameterDescriptor expectedThisObject;
|
||||
private Modality modality;
|
||||
private Visibility visibility;
|
||||
private final Set<FunctionDescriptor> overriddenFunctions = new LinkedHashSet<FunctionDescriptor>(); // LinkedHashSet is essential here
|
||||
private final FunctionDescriptor original;
|
||||
private final Kind kind;
|
||||
|
||||
|
||||
+3
-2
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.descriptors.impl;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -25,6 +24,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -144,7 +144,8 @@ public abstract class PropertyAccessorDescriptorImpl extends DeclarationDescript
|
||||
@NotNull
|
||||
protected Set<PropertyAccessorDescriptor> getOverriddenDescriptors(boolean isGetter) {
|
||||
Set<? extends PropertyDescriptor> overriddenProperties = getCorrespondingProperty().getOverriddenDescriptors();
|
||||
Set<PropertyAccessorDescriptor> overriddenAccessors = Sets.newLinkedHashSet(); // LinkedHashSet for determinism
|
||||
// LinkedHashSet for determinism
|
||||
Set<PropertyAccessorDescriptor> overriddenAccessors = new LinkedHashSet<PropertyAccessorDescriptor>();
|
||||
for (PropertyDescriptor overriddenProperty : overriddenProperties) {
|
||||
PropertyAccessorDescriptor accessorDescriptor = isGetter ? overriddenProperty.getGetter() : overriddenProperty.getSetter();
|
||||
if (accessorDescriptor != null) {
|
||||
|
||||
+2
-7
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.descriptors.impl;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -30,17 +29,13 @@ 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;
|
||||
import java.util.*;
|
||||
|
||||
public class PropertyDescriptorImpl extends VariableDescriptorImpl implements PropertyDescriptor {
|
||||
|
||||
private final Modality modality;
|
||||
private Visibility visibility;
|
||||
private final boolean isVar;
|
||||
private final Set<PropertyDescriptor> overriddenProperties = Sets.newLinkedHashSet(); // LinkedHashSet is essential here
|
||||
private final Set<PropertyDescriptor> overriddenProperties = new LinkedHashSet<PropertyDescriptor>(); // LinkedHashSet is essential here
|
||||
private final PropertyDescriptor original;
|
||||
private final Kind kind;
|
||||
|
||||
|
||||
+2
-2
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.descriptors.impl;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
@@ -32,6 +31,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.storage.LockBasedStorageManager;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor {
|
||||
@@ -62,7 +62,7 @@ public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor
|
||||
return new TypeParameterDescriptorImpl(containingDeclaration, annotations, reified, variance, name, index, source);
|
||||
}
|
||||
|
||||
private final Set<JetType> upperBounds = Sets.newLinkedHashSet();
|
||||
private final Set<JetType> upperBounds = new LinkedHashSet<JetType>();
|
||||
private boolean initialized = false;
|
||||
|
||||
private TypeParameterDescriptorImpl(
|
||||
|
||||
+2
-4
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.descriptors.impl;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
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.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ValueParameterDescriptorImpl extends VariableDescriptorImpl implements ValueParameterDescriptor {
|
||||
private Boolean hasDefaultValue;
|
||||
private final boolean declaresDefaultValue;
|
||||
|
||||
private final JetType varargElementType;
|
||||
private final int index;
|
||||
private final ValueParameterDescriptor original;
|
||||
|
||||
private final Set<ValueParameterDescriptor> overriddenDescriptors = Sets.newLinkedHashSet(); // Linked is essential
|
||||
private final Set<ValueParameterDescriptor> overriddenDescriptors = new LinkedHashSet<ValueParameterDescriptor>(); // Linked is essential
|
||||
private boolean overriddenDescriptorsLocked = false;
|
||||
private final Set<? extends ValueParameterDescriptor> readOnlyOverriddenDescriptors = Collections.unmodifiableSet(overriddenDescriptors);
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import kotlin.Function1;
|
||||
import kotlin.KotlinPackage;
|
||||
@@ -250,7 +249,7 @@ public class OverridingUtil {
|
||||
@NotNull ClassDescriptor current,
|
||||
@NotNull DescriptorSink sink
|
||||
) {
|
||||
Collection<CallableMemberDescriptor> notOverridden = Sets.newLinkedHashSet(membersFromSupertypes);
|
||||
Collection<CallableMemberDescriptor> notOverridden = new LinkedHashSet<CallableMemberDescriptor>(membersFromSupertypes);
|
||||
|
||||
for (CallableMemberDescriptor fromCurrent : membersFromCurrent) {
|
||||
Collection<CallableMemberDescriptor> bound =
|
||||
|
||||
+3
-3
@@ -16,13 +16,13 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls.inference;
|
||||
|
||||
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.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConstraintPosition {
|
||||
@@ -31,8 +31,8 @@ public class ConstraintPosition {
|
||||
public static final ConstraintPosition FROM_COMPLETER = new ConstraintPosition("FROM_COMPLETER", true);
|
||||
public static final ConstraintPosition SPECIAL = new ConstraintPosition("SPECIAL", true);
|
||||
|
||||
private static final Map<Integer, ConstraintPosition> valueParameterPositions = Maps.newHashMap();
|
||||
private static final Map<Integer, ConstraintPosition> typeBoundPositions = Maps.newHashMap();
|
||||
private static final Map<Integer, ConstraintPosition> valueParameterPositions = new HashMap<Integer, ConstraintPosition>();
|
||||
private static final Map<Integer, ConstraintPosition> typeBoundPositions = new HashMap<Integer, ConstraintPosition>();
|
||||
|
||||
public static ConstraintPosition getValueParameterPosition(int index) {
|
||||
ConstraintPosition position = valueParameterPositions.get(index);
|
||||
|
||||
+8
-12
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls.inference;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import kotlin.Function1;
|
||||
import kotlin.KotlinPackage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -30,10 +28,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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.EQUAL;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.SUB_TYPE;
|
||||
@@ -47,8 +42,9 @@ public class ConstraintSystemImpl implements ConstraintSystem {
|
||||
SUB_TYPE, EQUAL
|
||||
}
|
||||
|
||||
private final Map<TypeParameterDescriptor, TypeBoundsImpl> typeParameterBounds = Maps.newLinkedHashMap();
|
||||
private final Set<ConstraintPosition> errorConstraintPositions = Sets.newHashSet();
|
||||
private final Map<TypeParameterDescriptor, TypeBoundsImpl> typeParameterBounds =
|
||||
new LinkedHashMap<TypeParameterDescriptor, TypeBoundsImpl>();
|
||||
private final Set<ConstraintPosition> errorConstraintPositions = new HashSet<ConstraintPosition>();
|
||||
private boolean hasErrorInConstrainingTypes;
|
||||
|
||||
private final ConstraintSystemStatus constraintSystemStatus = new ConstraintSystemStatus() {
|
||||
@@ -123,7 +119,8 @@ public class ConstraintSystemImpl implements ConstraintSystem {
|
||||
@NotNull Map<TypeParameterDescriptor, TypeBoundsImpl> typeParameterBounds,
|
||||
@NotNull Function1<TypeParameterDescriptor, TypeProjection> getDefaultTypeProjection
|
||||
) {
|
||||
Map<TypeParameterDescriptor, TypeProjection> substitutionContext = Maps.newHashMap();
|
||||
Map<TypeParameterDescriptor, TypeProjection> substitutionContext =
|
||||
UtilsPackage.newHashMapWithExpectedSize(typeParameterBounds.size());
|
||||
for (Map.Entry<TypeParameterDescriptor, TypeBoundsImpl> entry : typeParameterBounds.entrySet()) {
|
||||
TypeParameterDescriptor typeParameter = entry.getKey();
|
||||
TypeBounds typeBounds = entry.getValue();
|
||||
@@ -221,12 +218,11 @@ public class ConstraintSystemImpl implements ConstraintSystem {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ConstraintSystem filterConstraintsOut(@NotNull ConstraintPosition... excludePositions) {
|
||||
final Set<ConstraintPosition> positions = Sets.newHashSet(excludePositions);
|
||||
public ConstraintSystem filterConstraintsOut(@NotNull final ConstraintPosition excludePosition) {
|
||||
return filterConstraints(new Function1<ConstraintPosition, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(ConstraintPosition constraintPosition) {
|
||||
return !positions.contains(constraintPosition);
|
||||
return !excludePosition.equals(constraintPosition);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+3
-4
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls.inference;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import kotlin.Function1;
|
||||
import kotlin.KotlinPackage;
|
||||
@@ -34,7 +33,7 @@ import static org.jetbrains.jet.lang.resolve.calls.inference.TypeBounds.BoundKin
|
||||
public class TypeBoundsImpl implements TypeBounds {
|
||||
private final TypeParameterDescriptor typeVariable;
|
||||
private final Variance varianceOfPosition;
|
||||
private final Set<Bound> bounds = Sets.newLinkedHashSet();
|
||||
private final Set<Bound> bounds = new LinkedHashSet<Bound>();
|
||||
|
||||
private Collection<JetType> resultValues;
|
||||
|
||||
@@ -88,7 +87,7 @@ public class TypeBoundsImpl implements TypeBounds {
|
||||
@NotNull BoundKind kind,
|
||||
@Nullable Collection<JetType> errorValues
|
||||
) {
|
||||
Set<JetType> result = Sets.newLinkedHashSet();
|
||||
Set<JetType> result = new LinkedHashSet<JetType>();
|
||||
for (Bound bound : bounds) {
|
||||
if (bound.kind == kind) {
|
||||
if (!ErrorUtils.containsErrorType(bound.type)) {
|
||||
@@ -142,7 +141,7 @@ public class TypeBoundsImpl implements TypeBounds {
|
||||
|
||||
@NotNull
|
||||
private Collection<JetType> computeValues() {
|
||||
Set<JetType> values = Sets.newLinkedHashSet();
|
||||
Set<JetType> values = new LinkedHashSet<JetType>();
|
||||
if (bounds.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -16,17 +16,13 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.scopes;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.utils.Printer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.scopes.JetScopeSelectorUtil.*;
|
||||
|
||||
@@ -106,7 +102,7 @@ public class ChainedScope implements JetScope {
|
||||
@Override
|
||||
public Collection<DeclarationDescriptor> getAllDescriptors() {
|
||||
if (allDescriptors == null) {
|
||||
allDescriptors = Sets.newHashSet();
|
||||
allDescriptors = new HashSet<DeclarationDescriptor>();
|
||||
for (JetScope scope : scopeChain) {
|
||||
allDescriptors.addAll(scope.getAllDescriptors());
|
||||
}
|
||||
|
||||
+4
-8
@@ -16,15 +16,12 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.scopes;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public class JetScopeSelectorUtil {
|
||||
private JetScopeSelectorUtil() {
|
||||
@@ -47,7 +44,7 @@ public class JetScopeSelectorUtil {
|
||||
|
||||
@NotNull
|
||||
public static <D extends DeclarationDescriptor> Collection<D> collect(Collection<JetScope> scopes, ScopeByNameMultiSelector<D> selector, Name name) {
|
||||
Set<D> descriptors = Sets.newHashSet();
|
||||
Set<D> descriptors = new HashSet<D>();
|
||||
|
||||
for (JetScope scope : scopes) {
|
||||
descriptors.addAll(selector.get(scope, name));
|
||||
@@ -58,7 +55,7 @@ public class JetScopeSelectorUtil {
|
||||
|
||||
@NotNull
|
||||
public static <D extends DeclarationDescriptor> Collection<D> collect(Collection<JetScope> scopes, ScopeDescriptorSelector<D> selector) {
|
||||
Set<D> descriptors = Sets.newHashSet();
|
||||
Set<D> descriptors = new HashSet<D>();
|
||||
|
||||
for (JetScope scope : scopes) {
|
||||
descriptors.addAll(selector.get(scope));
|
||||
@@ -146,8 +143,7 @@ public class JetScopeSelectorUtil {
|
||||
) {
|
||||
if (scopes.length == 0) return Collections.emptySet();
|
||||
|
||||
Set<D> descriptors = Sets.newLinkedHashSet();
|
||||
|
||||
Set<D> descriptors = new LinkedHashSet<D>();
|
||||
for (JetScope jetScope : scopes) {
|
||||
descriptors.addAll(descriptorsSelector.get(jetScope, name));
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.scopes;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
@@ -25,11 +23,9 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
import org.jetbrains.jet.utils.Printer;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public class SubstitutingScope implements JetScope {
|
||||
|
||||
@@ -50,7 +46,7 @@ public class SubstitutingScope implements JetScope {
|
||||
if (substitutor.isEmpty()) return descriptor;
|
||||
|
||||
if (substitutedDescriptors == null) {
|
||||
substitutedDescriptors = Maps.newHashMap();
|
||||
substitutedDescriptors = new HashMap<DeclarationDescriptor, DeclarationDescriptor>();
|
||||
}
|
||||
|
||||
DeclarationDescriptor substituted = substitutedDescriptors.get(descriptor);
|
||||
@@ -70,7 +66,7 @@ public class SubstitutingScope implements JetScope {
|
||||
if (substitutor.isEmpty()) return descriptors;
|
||||
if (descriptors.isEmpty()) return descriptors;
|
||||
|
||||
Set<D> result = Sets.newHashSetWithExpectedSize(descriptors.size());
|
||||
Set<D> result = UtilsPackage.newHashSetWithExpectedSize(descriptors.size());
|
||||
for (D descriptor : descriptors) {
|
||||
D substitute = substitute(descriptor);
|
||||
if (substitute != null) {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.types;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
@@ -107,7 +106,7 @@ public class CommonSupertypes {
|
||||
|
||||
List<TypeConstructor> order = null;
|
||||
for (JetType type : types) {
|
||||
Set<TypeConstructor> visited = Sets.newHashSet();
|
||||
Set<TypeConstructor> visited = new HashSet<TypeConstructor>();
|
||||
order = topologicallySortSuperclassesAndRecordAllInstances(type, constructorToAllInstances, visited);
|
||||
|
||||
if (commonSuperclasses == null) {
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.types;
|
||||
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
@@ -32,7 +30,7 @@ public class IntersectionTypeConstructor extends AnnotatedImpl implements TypeCo
|
||||
|
||||
public IntersectionTypeConstructor(Annotations annotations, Collection<JetType> typesToIntersect) {
|
||||
super(annotations);
|
||||
this.intersectedTypes = Sets.newLinkedHashSet(typesToIntersect);
|
||||
this.intersectedTypes = new LinkedHashSet<JetType>(typesToIntersect);
|
||||
this.hashCode = intersectedTypes.hashCode();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.types;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import kotlin.Function1;
|
||||
import kotlin.KotlinPackage;
|
||||
import kotlin.Unit;
|
||||
@@ -36,6 +34,7 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.utils.DFS;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -138,7 +137,7 @@ public class TypeUtils {
|
||||
}
|
||||
|
||||
public static boolean isIntersectionEmpty(@NotNull JetType typeA, @NotNull JetType typeB) {
|
||||
return intersect(JetTypeChecker.DEFAULT, Sets.newLinkedHashSet(Arrays.asList(typeA, typeB))) == null;
|
||||
return intersect(JetTypeChecker.DEFAULT, new LinkedHashSet<JetType>(Arrays.asList(typeA, typeB))) == null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -237,7 +236,7 @@ public class TypeUtils {
|
||||
|
||||
private static boolean unify(JetType withParameters, JetType expected) {
|
||||
// T -> how T is used
|
||||
final Map<TypeParameterDescriptor, Variance> parameters = Maps.newHashMap();
|
||||
final Map<TypeParameterDescriptor, Variance> parameters = new HashMap<TypeParameterDescriptor, Variance>();
|
||||
Function1<TypeParameterUsage, Unit> processor = new Function1<TypeParameterUsage, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(TypeParameterUsage parameterUsage) {
|
||||
@@ -469,7 +468,7 @@ public class TypeUtils {
|
||||
throw new IllegalArgumentException("type parameter counts do not match: " + clazz + ", " + projections);
|
||||
}
|
||||
|
||||
Map<TypeConstructor, TypeProjection> substitutions = Maps.newHashMap();
|
||||
Map<TypeConstructor, TypeProjection> substitutions = UtilsPackage.newHashMapWithExpectedSize(clazzTypeParameters.size());
|
||||
|
||||
for (int i = 0; i < clazzTypeParameters.size(); ++i) {
|
||||
TypeConstructor typeConstructor = clazzTypeParameters.get(i).getTypeConstructor();
|
||||
@@ -547,7 +546,7 @@ public class TypeUtils {
|
||||
|
||||
@NotNull
|
||||
private static Set<JetType> getIntersectionOfSupertypes(@NotNull Collection<JetType> types) {
|
||||
Set<JetType> upperBounds = Sets.newHashSet();
|
||||
Set<JetType> upperBounds = new HashSet<JetType>();
|
||||
for (JetType type : types) {
|
||||
Collection<JetType> supertypes = type.getConstructor().getSupertypes();
|
||||
if (upperBounds.isEmpty()) {
|
||||
@@ -654,7 +653,7 @@ public class TypeUtils {
|
||||
}
|
||||
|
||||
public static TypeSubstitutor makeConstantSubstitutor(Collection<TypeParameterDescriptor> typeParameterDescriptors, JetType type) {
|
||||
final Set<TypeConstructor> constructors = Sets.newHashSet();
|
||||
final Set<TypeConstructor> constructors = UtilsPackage.newHashSetWithExpectedSize(typeParameterDescriptors.size());
|
||||
for (TypeParameterDescriptor typeParameterDescriptor : typeParameterDescriptors) {
|
||||
constructors.add(typeParameterDescriptor.getTypeConstructor());
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.renderer;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import kotlin.Function1;
|
||||
import kotlin.KotlinPackage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -114,7 +113,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
||||
this.debugMode = debugMode;
|
||||
this.textFormat = textFormat;
|
||||
this.includePropertyConstant = includePropertyConstant;
|
||||
this.excludedAnnotationClasses = Sets.newHashSet(excludedAnnotationClasses);
|
||||
this.excludedAnnotationClasses = new HashSet<FqName>(excludedAnnotationClasses);
|
||||
this.prettyFunctionTypes = prettyFunctionTypes;
|
||||
this.uninferredTypeParameterAsName = uninferredTypeParameterAsName;
|
||||
this.includeSynthesizedParameterNames = includeSynthesizedParameterNames;
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.jetbrains.jet.utils
|
||||
|
||||
import java.util.LinkedHashMap
|
||||
import java.util.ArrayList
|
||||
import java.util.HashMap
|
||||
import java.util.HashSet
|
||||
|
||||
public fun <K, V> Stream<V>.valuesToMap(key: (V) -> K): Map<K, V> {
|
||||
val map = LinkedHashMap<K, V>()
|
||||
@@ -83,4 +85,12 @@ public fun <T: Any> emptyOrSingletonList(item: T?): List<T> = if (item == null)
|
||||
|
||||
public fun <T: Any> MutableCollection<T>.addIfNotNull(t: T?) {
|
||||
if (t != null) add(t)
|
||||
}
|
||||
}
|
||||
|
||||
public fun <K, V> newHashMapWithExpectedSize(expectedSize: Int): HashMap<K, V> {
|
||||
return HashMap(if (expectedSize < 3) 3 else expectedSize + expectedSize / 3 + 1)
|
||||
}
|
||||
|
||||
public fun <E> newHashSetWithExpectedSize(expectedSize: Int): HashSet<E> {
|
||||
return HashSet(if (expectedSize < 3) 3 else expectedSize + expectedSize / 3 + 1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user