diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/lang/KotlinBuiltIns.java b/core/descriptors/src/org/jetbrains/jet/lang/types/lang/KotlinBuiltIns.java index 33dea602a66..f2df1fbd048 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/lang/KotlinBuiltIns.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/lang/KotlinBuiltIns.java @@ -16,7 +16,6 @@ package org.jetbrains.jet.lang.types.lang; -import com.google.common.collect.ImmutableSet; import kotlin.KotlinPackage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -95,7 +94,7 @@ public class KotlinBuiltIns { private final ModuleDescriptorImpl builtInsModule; private final BuiltinsPackageFragment builtinsPackageFragment; - private volatile ImmutableSet nonPhysicalClasses; + private final Set nonPhysicalClasses; private final Map primitiveTypeToNullableJetType; private final Map primitiveTypeToArrayJetType; @@ -117,6 +116,8 @@ public class KotlinBuiltIns { primitiveTypeToArrayJetType = new EnumMap(PrimitiveType.class); primitiveJetTypeToJetArrayType = new HashMap(); jetArrayTypeToPrimitiveJetType = new HashMap(); + + nonPhysicalClasses = new HashSet(); } private void doInitialize() { @@ -124,7 +125,7 @@ public class KotlinBuiltIns { makePrimitive(primitive); } - nonPhysicalClasses = computeNonPhysicalClasses(); + computeNonPhysicalClasses(); } private void makePrimitive(@NotNull PrimitiveType primitiveType) { @@ -143,9 +144,8 @@ public class KotlinBuiltIns { public final FqNameUnsafe cloneable = fqName("Cloneable"); public final FqNameUnsafe suppress = fqName("suppress"); - public final ImmutableSet functionClasses = computeIndexedFqNames("Function", FUNCTION_TRAIT_COUNT); - public final ImmutableSet extensionFunctionClasses = - computeIndexedFqNames("ExtensionFunction", FUNCTION_TRAIT_COUNT); + public final Set functionClasses = computeIndexedFqNames("Function", FUNCTION_TRAIT_COUNT); + public final Set extensionFunctionClasses = computeIndexedFqNames("ExtensionFunction", FUNCTION_TRAIT_COUNT); @NotNull private static FqNameUnsafe fqName(@NotNull String simpleName) { @@ -153,12 +153,12 @@ public class KotlinBuiltIns { } @NotNull - private static ImmutableSet computeIndexedFqNames(@NotNull String prefix, int count) { - ImmutableSet.Builder builder = ImmutableSet.builder(); + private static Set computeIndexedFqNames(@NotNull String prefix, int count) { + Set result = new HashSet(); for (int i = 0; i < count; i++) { - builder.add(fqName(prefix + i)); + result.add(fqName(prefix + i)); } - return builder.build(); + return result; } } @@ -260,7 +260,7 @@ public class KotlinBuiltIns { @NotNull public Set getIntegralRanges() { - return ImmutableSet.of( + return KotlinPackage.setOf( getBuiltInClassByName("ByteRange"), getBuiltInClassByName("ShortRange"), getBuiltInClassByName("CharRange"), @@ -454,13 +454,11 @@ public class KotlinBuiltIns { */ @NotNull public Set getNonPhysicalClasses() { - return nonPhysicalClasses; + return Collections.unmodifiableSet(nonPhysicalClasses); } - @NotNull - private ImmutableSet computeNonPhysicalClasses() { - ImmutableSet.Builder nonPhysical = ImmutableSet.builder(); - nonPhysical.add( + private void computeNonPhysicalClasses() { + nonPhysicalClasses.addAll(Arrays.asList( getAny(), getNothing(), @@ -492,14 +490,12 @@ public class KotlinBuiltIns { getComparable(), getEnum(), getArray() - ); + )); for (PrimitiveType primitiveType : values()) { - nonPhysical.add(getPrimitiveClassDescriptor(primitiveType)); - nonPhysical.add(getPrimitiveArrayClassDescriptor(primitiveType)); + nonPhysicalClasses.add(getPrimitiveClassDescriptor(primitiveType)); + nonPhysicalClasses.add(getPrimitiveArrayClassDescriptor(primitiveType)); } - - return nonPhysical.build(); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -761,7 +757,7 @@ public class KotlinBuiltIns { return isTypeConstructorFqNameInSet(type, fqNames.extensionFunctionClasses); } - private static boolean isTypeConstructorFqNameInSet(@NotNull JetType type, @NotNull ImmutableSet classes) { + private static boolean isTypeConstructorFqNameInSet(@NotNull JetType type, @NotNull Set classes) { ClassifierDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor(); if (declarationDescriptor == null) return false; diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/lang/PrimitiveType.java b/core/descriptors/src/org/jetbrains/jet/lang/types/lang/PrimitiveType.java index 396d96af5b8..0ef2de15973 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/lang/PrimitiveType.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/lang/PrimitiveType.java @@ -16,10 +16,13 @@ package org.jetbrains.jet.lang.types.lang; -import com.google.common.collect.ImmutableSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.resolve.name.Name; +import java.util.Collections; +import java.util.EnumSet; +import java.util.Set; + public enum PrimitiveType { BOOLEAN("Boolean"), CHAR("Char"), @@ -31,7 +34,8 @@ public enum PrimitiveType { DOUBLE("Double"), ; - public static final ImmutableSet NUMBER_TYPES = ImmutableSet.of(CHAR, BYTE, SHORT, INT, FLOAT, LONG, DOUBLE); + public static final Set NUMBER_TYPES = + Collections.unmodifiableSet(EnumSet.of(CHAR, BYTE, SHORT, INT, FLOAT, LONG, DOUBLE)); private final Name typeName; private final Name arrayTypeName; diff --git a/core/descriptors/src/org/jetbrains/jet/renderer/DescriptorRendererBuilder.java b/core/descriptors/src/org/jetbrains/jet/renderer/DescriptorRendererBuilder.java index 82dbdc85d49..4fb1d86fdaf 100644 --- a/core/descriptors/src/org/jetbrains/jet/renderer/DescriptorRendererBuilder.java +++ b/core/descriptors/src/org/jetbrains/jet/renderer/DescriptorRendererBuilder.java @@ -16,18 +16,19 @@ package org.jetbrains.jet.renderer; -import com.google.common.collect.ImmutableSet; +import kotlin.KotlinPackage; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.resolve.name.FqName; import java.util.Collection; import java.util.Collections; +import java.util.EnumSet; import java.util.Set; public class DescriptorRendererBuilder { private boolean shortNames = false; private boolean withDefinedIn = true; - private Set modifiers = ImmutableSet.copyOf(DescriptorRenderer.Modifier.values()); + private Set modifiers = EnumSet.allOf(DescriptorRenderer.Modifier.class); private boolean startFromName = false; private boolean debugMode = false; private boolean classWithPrimaryConstructor = false; @@ -77,7 +78,7 @@ public class DescriptorRendererBuilder { @NotNull public DescriptorRendererBuilder setModifiers(DescriptorRenderer.Modifier... modifiers) { - return setModifiers(ImmutableSet.copyOf(modifiers)); + return setModifiers(KotlinPackage.setOf(modifiers)); } @NotNull