JetStandardLibrary -> KotlinBuiltIns

This commit is contained in:
Andrey Breslav
2012-10-17 12:04:52 +04:00
parent c719ae427a
commit e81f38b6a8
68 changed files with 287 additions and 314 deletions
@@ -26,7 +26,6 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.ImportPath;
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import java.util.Collection;
@@ -61,7 +60,7 @@ public class DefaultModuleConfiguration implements ModuleConfiguration {
if (DescriptorUtils.getFQName(namespaceDescriptor).equalsTo(KotlinBuiltIns.getInstance().getBuiltInsPackageFqName())) {
switch (builtinsScopeExtensionMode) {
case ALL:
namespaceMemberScope.importScope(JetStandardLibrary.getInstance().getLibraryScope());
namespaceMemberScope.importScope(KotlinBuiltIns.getInstance().getBuiltInsScope());
break;
case ONLY_STANDARD_CLASSES:
namespaceMemberScope.importScope(KotlinBuiltIns.getInstance().getBuiltInsScope());
@@ -35,7 +35,6 @@ import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstantResolver;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.expressions.OperatorConventions;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lexer.JetTokens;
import java.util.Iterator;
@@ -432,7 +431,7 @@ public class JetControlFlowProcessor {
}
boolean conditionIsTrueConstant = false;
if (condition instanceof JetConstantExpression && condition.getNode().getElementType() == JetNodeTypes.BOOLEAN_CONSTANT) {
if (BooleanValue.TRUE == new CompileTimeConstantResolver().getBooleanValue(condition.getText(), JetStandardLibrary.getInstance().getBooleanType())) {
if (BooleanValue.TRUE == new CompileTimeConstantResolver().getBooleanValue(condition.getText(), KotlinBuiltIns.getInstance().getBooleanType())) {
conditionIsTrueConstant = true;
}
}
@@ -29,7 +29,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
import org.jetbrains.jet.lang.types.ErrorUtils;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.resolve.DescriptorRenderer;
import javax.inject.Inject;
@@ -224,7 +224,7 @@ public class DeclarationResolver {
JetClass jetClass = entry.getKey();
MutableClassDescriptor classDescriptor = entry.getValue();
if (jetClass.hasPrimaryConstructor() && JetStandardLibrary.isData(classDescriptor)) {
if (jetClass.hasPrimaryConstructor() && KotlinBuiltIns.getInstance().isData(classDescriptor)) {
createComponentFunctions(classDescriptor);
}
}
@@ -38,7 +38,6 @@ import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lexer.JetTokens;
import org.jetbrains.jet.util.lazy.LazyValue;
import org.jetbrains.jet.util.lazy.LazyValueWithDefault;
@@ -140,7 +139,7 @@ public class DescriptorResolver {
}
if (classDescriptor.getKind() == ClassKind.ENUM_CLASS && !containsClass(supertypes)) {
supertypes.add(0, JetStandardLibrary.getInstance().getEnumType(classDescriptor.getDefaultType()));
supertypes.add(0, KotlinBuiltIns.getInstance().getEnumType(classDescriptor.getDefaultType()));
}
if (supertypes.isEmpty()) {
@@ -181,7 +180,7 @@ public class DescriptorResolver {
}
}
else if (jetClass instanceof JetClass && ((JetClass) jetClass).isAnnotation()) {
return JetStandardLibrary.getInstance().getAnnotationType();
return KotlinBuiltIns.getInstance().getAnnotationType();
}
return KotlinBuiltIns.getInstance().getAnyType();
}
@@ -425,12 +424,12 @@ public class DescriptorResolver {
}
private JetType getVarargParameterType(JetType type) {
JetType arrayType = JetStandardLibrary.getInstance().getPrimitiveArrayJetTypeByPrimitiveJetType(type);
JetType arrayType = KotlinBuiltIns.getInstance().getPrimitiveArrayJetTypeByPrimitiveJetType(type);
if (arrayType != null) {
return arrayType;
}
else {
return JetStandardLibrary.getInstance().getArrayType(type);
return KotlinBuiltIns.getInstance().getArrayType(type);
}
}
@@ -1179,7 +1178,7 @@ public class DescriptorResolver {
JetType type = DeferredType.create(trace, new LazyValue<JetType>() {
@Override
protected JetType compute() {
return JetStandardLibrary.getInstance().getArrayType(enumClassDescriptor.getDefaultType());
return KotlinBuiltIns.getInstance().getArrayType(enumClassDescriptor.getDefaultType());
}
});
values.initialize(null, classReceiver, Collections.<TypeParameterDescriptor>emptyList(),
@@ -1213,7 +1212,7 @@ public class DescriptorResolver {
Collections.<AnnotationDescriptor>emptyList(),
Name.identifier("value"),
false,
JetStandardLibrary.getInstance().getStringType(),
KotlinBuiltIns.getInstance().getStringType(),
false,
null);
values.initialize(null, classReceiver,
@@ -33,7 +33,6 @@ import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeUtils;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import java.util.*;
@@ -292,7 +291,7 @@ public class DescriptorUtils {
}
public static boolean isIteratorWithoutRemoveImpl(@NotNull ClassDescriptor classDescriptor) {
ClassDescriptor iteratorOfT = JetStandardLibrary.getInstance().getIterator();
ClassDescriptor iteratorOfT = KotlinBuiltIns.getInstance().getIterator();
JetType iteratorOfAny = TypeUtils.substituteParameters(iteratorOfT, Collections.singletonList(KotlinBuiltIns.getInstance().getAnyType()));
boolean isIterator = JetTypeChecker.INSTANCE.isSubtypeOf(classDescriptor.getDefaultType(), iteratorOfAny);
boolean hasRemove = hasMethod(classDescriptor, Name.identifier("remove"));
@@ -33,7 +33,7 @@ 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.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lexer.JetTokens;
import org.jetbrains.jet.util.CommonSuppliers;
@@ -741,7 +741,7 @@ public class OverrideResolver {
@NotNull
private JetAnnotationEntry findDataAnnotationForDataClass(@NotNull DeclarationDescriptor dataClass) {
ClassDescriptor stdDataClassAnnotation = JetStandardLibrary.getInstance().getDataClassAnnotation();
ClassDescriptor stdDataClassAnnotation = KotlinBuiltIns.getInstance().getDataClassAnnotation();
for (AnnotationDescriptor annotation : dataClass.getAnnotations()) {
if (stdDataClassAnnotation.equals(annotation.getType().getConstructor().getDeclarationDescriptor())) {
return BindingContextUtils.getNotNull(trace.getBindingContext(),
@@ -29,7 +29,7 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeUtils;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import java.util.List;
import java.util.Set;
@@ -200,13 +200,13 @@ public class OverloadingConflictResolver {
}
private boolean numericTypeMoreSpecific(@NotNull JetType specific, @NotNull JetType general) {
JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
JetType _double = standardLibrary.getDoubleType();
JetType _float = standardLibrary.getFloatType();
JetType _long = standardLibrary.getLongType();
JetType _int = standardLibrary.getIntType();
JetType _byte = standardLibrary.getByteType();
JetType _short = standardLibrary.getShortType();
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
JetType _double = builtIns.getDoubleType();
JetType _float = builtIns.getFloatType();
JetType _long = builtIns.getLongType();
JetType _int = builtIns.getIntType();
JetType _byte = builtIns.getByteType();
JetType _short = builtIns.getShortType();
if (TypeUtils.equalTypes(specific, _double) && TypeUtils.equalTypes(general, _float)) return true;
if (TypeUtils.equalTypes(specific, _int)) {
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
/**
* @author Natalia Ukhorskaya
@@ -41,7 +41,7 @@ public class AnnotationValue implements CompileTimeConstant<AnnotationDescriptor
@Override
@NotNull
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
return value.getType();
}
@@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.resolve.constants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import java.util.List;
@@ -44,7 +44,7 @@ public class ArrayValue implements CompileTimeConstant<List<CompileTimeConstant<
@NotNull
@Override
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
return type;
}
@@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.resolve.constants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.JetType;
/**
@@ -42,8 +42,8 @@ public class BooleanValue implements CompileTimeConstant<Boolean> {
@NotNull
@Override
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
return standardLibrary.getBooleanType();
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
return kotlinBuiltIns.getBooleanType();
}
@Override
@@ -20,7 +20,7 @@ import com.google.common.base.Function;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.JetType;
/**
@@ -48,8 +48,8 @@ public class ByteValue implements CompileTimeConstant<Byte> {
@NotNull
@Override
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
return standardLibrary.getByteType();
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
return kotlinBuiltIns.getByteType();
}
@Override
@@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.resolve.constants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.JetType;
/**
@@ -39,8 +39,8 @@ public class CharValue implements CompileTimeConstant<Character> {
@NotNull
@Override
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
return standardLibrary.getCharType();
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
return kotlinBuiltIns.getCharType();
}
@Override
@@ -18,8 +18,8 @@ package org.jetbrains.jet.lang.resolve.constants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
/**
* @author abreslav
@@ -28,7 +28,7 @@ public interface CompileTimeConstant<T> {
T getValue();
@NotNull
JetType getType(@NotNull JetStandardLibrary standardLibrary);
JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns);
<R, D> R accept(AnnotationArgumentVisitor<R, D> visitor, D data);
}
@@ -23,11 +23,9 @@ import org.jetbrains.jet.lang.psi.JetEscapeStringTemplateEntry;
import org.jetbrains.jet.lang.psi.JetLiteralStringTemplateEntry;
import org.jetbrains.jet.lang.psi.JetStringTemplateEntry;
import org.jetbrains.jet.lang.psi.JetVisitorVoid;
import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import java.util.List;
@@ -37,10 +35,10 @@ import java.util.List;
public class CompileTimeConstantResolver {
public static final ErrorValue OUT_OF_RANGE = new ErrorValue("The value is out of range");
private final JetStandardLibrary standardLibrary;
private final KotlinBuiltIns builtIns;
public CompileTimeConstantResolver() {
this.standardLibrary = JetStandardLibrary.getInstance();
this.builtIns = KotlinBuiltIns.getInstance();
}
@NotNull
@@ -60,30 +58,30 @@ public class CompileTimeConstantResolver {
long lowerBound;
long upperBound;
TypeConstructor constructor = expectedType.getConstructor();
if (constructor == standardLibrary.getInt().getTypeConstructor()) {
if (constructor == builtIns.getInt().getTypeConstructor()) {
create = IntValue.CREATE;
lowerBound = Integer.MIN_VALUE;
upperBound = Integer.MAX_VALUE;
}
else if (constructor == standardLibrary.getLong().getTypeConstructor()) {
else if (constructor == builtIns.getLong().getTypeConstructor()) {
create = LongValue.CREATE;
lowerBound = Long.MIN_VALUE;
upperBound = Long.MAX_VALUE;
}
else if (constructor == standardLibrary.getShort().getTypeConstructor()) {
else if (constructor == builtIns.getShort().getTypeConstructor()) {
create = ShortValue.CREATE;
lowerBound = Short.MIN_VALUE;
upperBound = Short.MAX_VALUE;
}
else if (constructor == standardLibrary.getByte().getTypeConstructor()) {
else if (constructor == builtIns.getByte().getTypeConstructor()) {
create = ByteValue.CREATE;
lowerBound = Byte.MIN_VALUE;
upperBound = Byte.MAX_VALUE;
}
else {
JetTypeChecker typeChecker = JetTypeChecker.INSTANCE;
JetType intType = standardLibrary.getIntType();
JetType longType = standardLibrary.getLongType();
JetType intType = builtIns.getIntType();
JetType longType = builtIns.getLongType();
if (typeChecker.isSubtypeOf(intType, expectedType)) {
return getIntegerValue(text, intType);
}
@@ -127,7 +125,7 @@ public class CompileTimeConstantResolver {
@NotNull
public CompileTimeConstant<?> getFloatValue(@NotNull String text, @NotNull JetType expectedType) {
if (noExpectedType(expectedType)
|| JetTypeChecker.INSTANCE.isSubtypeOf(standardLibrary.getDoubleType(), expectedType)) {
|| JetTypeChecker.INSTANCE.isSubtypeOf(builtIns.getDoubleType(), expectedType)) {
try {
return new DoubleValue(Double.parseDouble(text));
}
@@ -135,7 +133,7 @@ public class CompileTimeConstantResolver {
return OUT_OF_RANGE;
}
}
else if (JetTypeChecker.INSTANCE.isSubtypeOf(standardLibrary.getFloatType(), expectedType)) {
else if (JetTypeChecker.INSTANCE.isSubtypeOf(builtIns.getFloatType(), expectedType)) {
try {
return new DoubleValue(Float.parseFloat(text));
}
@@ -159,7 +157,7 @@ public class CompileTimeConstantResolver {
@NotNull
public CompileTimeConstant<?> getBooleanValue(@NotNull String text, @NotNull JetType expectedType) {
CompileTimeConstant<?> error = checkNativeType(text, expectedType, "boolean", standardLibrary.getBooleanType());
CompileTimeConstant<?> error = checkNativeType(text, expectedType, "boolean", builtIns.getBooleanType());
if (error != null) {
return error;
}
@@ -174,7 +172,7 @@ public class CompileTimeConstantResolver {
@NotNull
public CompileTimeConstant<?> getCharValue(@NotNull String text, @NotNull JetType expectedType) {
CompileTimeConstant<?> error = checkNativeType(text, expectedType, "character", standardLibrary.getCharType());
CompileTimeConstant<?> error = checkNativeType(text, expectedType, "character", builtIns.getCharType());
if (error != null) {
return error;
}
@@ -260,7 +258,7 @@ public class CompileTimeConstantResolver {
@NotNull
public CompileTimeConstant<?> getRawStringValue(@NotNull String unescapedText, @NotNull JetType expectedType) {
CompileTimeConstant<?> error = checkNativeType("\"\"\"...\"\"\"", expectedType, "string", standardLibrary.getStringType());
CompileTimeConstant<?> error = checkNativeType("\"\"\"...\"\"\"", expectedType, "string", builtIns.getStringType());
if (error != null) {
return error;
}
@@ -270,7 +268,7 @@ public class CompileTimeConstantResolver {
@NotNull
public CompileTimeConstant<?> getEscapedStringValue(@NotNull List<JetStringTemplateEntry> entries, @NotNull JetType expectedType) {
CompileTimeConstant<?> error = checkNativeType("\"...\"", expectedType, "string", standardLibrary.getStringType());
CompileTimeConstant<?> error = checkNativeType("\"...\"", expectedType, "string", builtIns.getStringType());
if (error != null) {
return error;
}
@@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.resolve.constants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.JetType;
/**
@@ -38,8 +38,8 @@ public class DoubleValue implements CompileTimeConstant<Double> {
@NotNull
@Override
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
return standardLibrary.getDoubleType();
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
return kotlinBuiltIns.getDoubleType();
}
@Override
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
/**
* @author Natalia.Ukhorskaya
@@ -41,7 +41,7 @@ public class EnumValue implements CompileTimeConstant<PropertyDescriptor> {
@NotNull
@Override
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
return value.getType();
}
@@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.resolve.constants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.types.ErrorUtils;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.JetType;
/**
@@ -40,7 +40,7 @@ public class ErrorValue implements CompileTimeConstant<Void> {
@NotNull
@Override
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
return ErrorUtils.createErrorType(message);
}
@@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.resolve.constants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.JetType;
/**
@@ -38,8 +38,8 @@ public class FloatValue implements CompileTimeConstant<Float> {
@NotNull
@Override
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
return standardLibrary.getFloatType();
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
return kotlinBuiltIns.getFloatType();
}
@Override
@@ -20,7 +20,7 @@ import com.google.common.base.Function;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.JetType;
/**
@@ -48,8 +48,8 @@ public class IntValue implements CompileTimeConstant<Integer> {
@NotNull
@Override
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
return standardLibrary.getIntType();
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
return kotlinBuiltIns.getIntType();
}
@Override
@@ -20,7 +20,7 @@ import com.google.common.base.Function;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.JetType;
/**
@@ -47,8 +47,8 @@ public class LongValue implements CompileTimeConstant<Long> {
@NotNull
@Override
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
return standardLibrary.getLongType();
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
return kotlinBuiltIns.getLongType();
}
@Override
@@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.resolve.constants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.JetType;
/**
@@ -39,7 +38,7 @@ public class NullValue implements CompileTimeConstant<Void> {
@NotNull
@Override
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
return KotlinBuiltIns.getInstance().getNullableNothingType();
}
@@ -20,7 +20,7 @@ import com.google.common.base.Function;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.JetType;
/**
@@ -48,8 +48,8 @@ public class ShortValue implements CompileTimeConstant<Short> {
@NotNull
@Override
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
return standardLibrary.getShortType();
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
return kotlinBuiltIns.getShortType();
}
@Override
@@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.resolve.constants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.JetType;
/**
@@ -39,8 +39,8 @@ public class StringValue implements CompileTimeConstant<String> {
@NotNull
@Override
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
return standardLibrary.getStringType();
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
return kotlinBuiltIns.getStringType();
}
@Override
@@ -31,7 +31,7 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import org.jetbrains.jet.lang.types.DeferredType;
import org.jetbrains.jet.lang.types.ErrorUtils;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.util.lazy.LazyValue;
import java.util.*;
@@ -151,7 +151,7 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
}
private void generateDataClassMethods(@NotNull Collection<FunctionDescriptor> result, @NotNull Name name) {
if (!JetStandardLibrary.isData(thisDescriptor)) return;
if (!KotlinBuiltIns.getInstance().isData(thisDescriptor)) return;
ConstructorDescriptor constructor = getPrimaryConstructor();
if (constructor == null) return;
@@ -294,7 +294,7 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
}
private void addDataClassMethods() {
if (!JetStandardLibrary.isData(thisDescriptor)) return;
if (!KotlinBuiltIns.getInstance().isData(thisDescriptor)) return;
ConstructorDescriptor constructor = getPrimaryConstructor();
if (constructor == null) return;
@@ -46,7 +46,6 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ThisReceiverDescriptor;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lexer.JetTokens;
import java.util.*;
@@ -155,7 +154,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
ASTNode node = expression.getNode();
IElementType elementType = node.getElementType();
String text = node.getText();
JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
CompileTimeConstantResolver compileTimeConstantResolver = context.getCompileTimeConstantResolver();
CompileTimeConstant<?> value;
@@ -184,7 +183,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
}
else {
context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, value);
return DataFlowUtils.checkType(value.getType(standardLibrary), expression, context, context.dataFlowInfo);
return DataFlowUtils.checkType(value.getType(builtIns), expression, context, context.dataFlowInfo);
}
}
@@ -585,7 +584,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
CompileTimeConstant<?> wholeExpressionValue = context.trace.getBindingContext().get(BindingContext.COMPILE_TIME_VALUE, expression);
DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().get(BindingContext.REFERENCE_TARGET, selectorExpression);
if (wholeExpressionValue == null && receiverValue != null && !(receiverValue instanceof ErrorValue) && receiverValue.getValue() instanceof Number
&& JetStandardLibrary.getInstance().getNumber() == declarationDescriptor) {
&& KotlinBuiltIns.getInstance().getNumber() == declarationDescriptor) {
Number value = (Number) receiverValue.getValue();
Name referencedName = selectorExpression.getReferencedNameAsName();
if (OperatorConventions.NUMBER_CONVERSIONS.contains(referencedName)) {
@@ -976,10 +975,10 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
JetType compareToReturnType = getTypeForBinaryCall(context.scope, Name.identifier("compareTo"), context, expression);
if (compareToReturnType != null && !ErrorUtils.isErrorType(compareToReturnType)) {
TypeConstructor constructor = compareToReturnType.getConstructor();
JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
TypeConstructor intTypeConstructor = standardLibrary.getInt().getTypeConstructor();
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
TypeConstructor intTypeConstructor = builtIns.getInt().getTypeConstructor();
if (constructor.equals(intTypeConstructor)) {
result = standardLibrary.getBooleanType();
result = builtIns.getBooleanType();
}
else {
context.trace.report(COMPARE_TO_TYPE_MISMATCH.on(operationSign, compareToReturnType));
@@ -987,7 +986,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
}
}
else {
JetType booleanType = JetStandardLibrary.getInstance().getBooleanType();
JetType booleanType = KotlinBuiltIns.getInstance().getBooleanType();
if (OperatorConventions.EQUALS_OPERATIONS.contains(operationType)) {
Name name = Name.identifier("equals");
if (right != null) {
@@ -1222,7 +1221,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
if (value[0] != CompileTimeConstantResolver.OUT_OF_RANGE) {
context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new StringValue(builder.toString()));
}
return DataFlowUtils.checkType(JetStandardLibrary.getInstance().getStringType(), expression, contextWithExpectedType, context.dataFlowInfo);
return DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getStringType(), expression, contextWithExpectedType, context.dataFlowInfo);
}
@Override
@@ -43,7 +43,6 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.TransientReceiver;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.util.slicedmap.WritableSlice;
import java.util.ArrayList;
@@ -408,7 +407,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
if (catchParameter != null) {
VariableDescriptor variableDescriptor = context.expressionTypingServices.getDescriptorResolver().resolveLocalVariableDescriptor(
context.scope.getContainingDeclaration(), context.scope, catchParameter, context.trace);
JetType throwableType = JetStandardLibrary.getInstance().getThrowable().getDefaultType();
JetType throwableType = KotlinBuiltIns.getInstance().getThrowable().getDefaultType();
DataFlowUtils.checkType(variableDescriptor.getType(), catchParameter, context.replaceExpectedType(throwableType));
if (catchBody != null) {
WritableScope catchScope = newWritableScopeImpl(context, "Catch scope");
@@ -439,7 +438,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
public JetTypeInfo visitThrowExpression(JetThrowExpression expression, ExpressionTypingContext context) {
JetExpression thrownExpression = expression.getThrownExpression();
if (thrownExpression != null) {
JetType throwableType = JetStandardLibrary.getInstance().getThrowable().getDefaultType();
JetType throwableType = KotlinBuiltIns.getInstance().getThrowable().getDefaultType();
facade.getTypeInfo(thrownExpression, context.replaceExpectedType(throwableType).replaceScope(context.scope));
}
return DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getNothingType(), expression, context, context.dataFlowInfo);
@@ -44,7 +44,6 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.util.slicedmap.WritableSlice;
import java.util.ArrayList;
@@ -88,7 +87,7 @@ public class ExpressionTypingUtils {
}
public static boolean isBoolean(@NotNull JetType type) {
return JetTypeChecker.INSTANCE.isSubtypeOf(type, JetStandardLibrary.getInstance().getBooleanType());
return JetTypeChecker.INSTANCE.isSubtypeOf(type, KotlinBuiltIns.getInstance().getBooleanType());
}
public static boolean ensureBooleanResult(JetExpression operationSign, Name name, JetType resultType, ExpressionTypingContext context) {
@@ -99,7 +98,7 @@ public class ExpressionTypingUtils {
if (resultType != null) {
// TODO : Relax?
if (!isBoolean(resultType)) {
context.trace.report(RESULT_TYPE_MISMATCH.on(operationSign, subjectName, JetStandardLibrary.getInstance().getBooleanType(), resultType));
context.trace.report(RESULT_TYPE_MISMATCH.on(operationSign, subjectName, KotlinBuiltIns.getInstance().getBooleanType(), resultType));
return false;
}
}
@@ -109,16 +108,16 @@ public class ExpressionTypingUtils {
@NotNull
public static JetType getDefaultType(IElementType constantType) {
if (constantType == JetNodeTypes.INTEGER_CONSTANT) {
return JetStandardLibrary.getInstance().getIntType();
return KotlinBuiltIns.getInstance().getIntType();
}
else if (constantType == JetNodeTypes.FLOAT_CONSTANT) {
return JetStandardLibrary.getInstance().getDoubleType();
return KotlinBuiltIns.getInstance().getDoubleType();
}
else if (constantType == JetNodeTypes.BOOLEAN_CONSTANT) {
return JetStandardLibrary.getInstance().getBooleanType();
return KotlinBuiltIns.getInstance().getBooleanType();
}
else if (constantType == JetNodeTypes.CHARACTER_CONSTANT) {
return JetStandardLibrary.getInstance().getCharType();
return KotlinBuiltIns.getInstance().getCharType();
}
else if (constantType == JetNodeTypes.NULL) {
return KotlinBuiltIns.getInstance().getNullableNothingType();
@@ -30,7 +30,6 @@ import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import java.util.Collections;
import java.util.Set;
@@ -56,7 +55,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
DataFlowInfo newDataFlowInfo = checkTypeForIs(context, knownType, expression.getTypeRef(), dataFlowValue).thenInfo;
context.trace.record(BindingContext.DATAFLOW_INFO_AFTER_CONDITION, expression, newDataFlowInfo);
}
return DataFlowUtils.checkType(JetStandardLibrary.getInstance().getBooleanType(), expression, contextWithExpectedType, context.dataFlowInfo);
return DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getBooleanType(), expression, contextWithExpectedType, context.dataFlowInfo);
}
@Override
@@ -230,7 +229,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
return noChange(context);
}
if (conditionExpected) {
JetType booleanType = JetStandardLibrary.getInstance().getBooleanType();
JetType booleanType = KotlinBuiltIns.getInstance().getBooleanType();
if (!JetTypeChecker.INSTANCE.equalTypes(booleanType, type)) {
context.trace.report(TYPE_MISMATCH_IN_CONDITION.on(expression, type));
}