JetStandardLibrary -> KotlinBuiltIns
This commit is contained in:
@@ -37,7 +37,7 @@ import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
||||
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.lexer.JetTokens;
|
||||
|
||||
import java.util.List;
|
||||
@@ -55,13 +55,13 @@ import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.JAVA_STRING_T
|
||||
*/
|
||||
public class AsmUtil {
|
||||
private static final Set<ClassDescriptor> PRIMITIVE_NUMBER_CLASSES = Sets.newHashSet(
|
||||
JetStandardLibrary.getInstance().getByte(),
|
||||
JetStandardLibrary.getInstance().getShort(),
|
||||
JetStandardLibrary.getInstance().getInt(),
|
||||
JetStandardLibrary.getInstance().getLong(),
|
||||
JetStandardLibrary.getInstance().getFloat(),
|
||||
JetStandardLibrary.getInstance().getDouble(),
|
||||
JetStandardLibrary.getInstance().getChar()
|
||||
KotlinBuiltIns.getInstance().getByte(),
|
||||
KotlinBuiltIns.getInstance().getShort(),
|
||||
KotlinBuiltIns.getInstance().getInt(),
|
||||
KotlinBuiltIns.getInstance().getLong(),
|
||||
KotlinBuiltIns.getInstance().getFloat(),
|
||||
KotlinBuiltIns.getInstance().getDouble(),
|
||||
KotlinBuiltIns.getInstance().getChar()
|
||||
);
|
||||
|
||||
private static final int NO_FLAG_LOCAL = 0;
|
||||
|
||||
@@ -55,7 +55,6 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.*;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
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 org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
@@ -79,7 +78,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
private static final String CLASS_NO_PATTERN_MATCHED_EXCEPTION = "jet/NoPatternMatchedException";
|
||||
private static final String CLASS_TYPE_CAST_EXCEPTION = "jet/TypeCastException";
|
||||
public static final Set<DeclarationDescriptor> INTEGRAL_RANGES = JetStandardLibrary.getInstance().getIntegralRanges();
|
||||
public static final Set<DeclarationDescriptor> INTEGRAL_RANGES = KotlinBuiltIns.getInstance().getIntegralRanges();
|
||||
|
||||
private int myLastLineNumber = -1;
|
||||
|
||||
@@ -651,7 +650,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
invokeFunction(fakeCall, StackValue.local(iteratorVarIndex, asmTypeForIterator), hasNextCall);
|
||||
|
||||
JetType type = hasNextCall.getResultingDescriptor().getReturnType();
|
||||
assert type != null && JetTypeChecker.INSTANCE.isSubtypeOf(type, JetStandardLibrary.getInstance().getBooleanType());
|
||||
assert type != null && JetTypeChecker.INSTANCE.isSubtypeOf(type, KotlinBuiltIns.getInstance().getBooleanType());
|
||||
|
||||
Type asmType = asmType(type);
|
||||
StackValue.coerce(asmType, Type.BOOLEAN_TYPE, v);
|
||||
@@ -723,7 +722,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
protected void assignToLoopParameter(int parameterIndex) {
|
||||
Type arrayElParamType;
|
||||
Type asmElementType = asmType(elementType);
|
||||
if (JetStandardLibrary.getInstance().isArray(loopRangeType)) {
|
||||
if (KotlinBuiltIns.getInstance().isArray(loopRangeType)) {
|
||||
arrayElParamType = boxType(asmElementType);
|
||||
}
|
||||
else {
|
||||
@@ -2873,7 +2872,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
args.addAll(expression.getFunctionLiteralArguments());
|
||||
|
||||
boolean isArray = JetStandardLibrary.getInstance().isArray(arrayType);
|
||||
boolean isArray = KotlinBuiltIns.getInstance().isArray(arrayType);
|
||||
if (isArray) {
|
||||
// if (args.size() != 2 && !arrayType.getArguments().get(0).getType().isNullable()) {
|
||||
// throw new CompilationException("array constructor of non-nullable type requires two arguments");
|
||||
@@ -2943,13 +2942,13 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
assert operationDescriptor != null;
|
||||
if (arrayType.getSort() == Type.ARRAY &&
|
||||
indices.size() == 1 &&
|
||||
operationDescriptor.getValueParameters().get(0).getType().equals(JetStandardLibrary.getInstance().getIntType())) {
|
||||
operationDescriptor.getValueParameters().get(0).getType().equals(KotlinBuiltIns.getInstance().getIntType())) {
|
||||
gen(array, arrayType);
|
||||
for (JetExpression index : indices) {
|
||||
gen(index, Type.INT_TYPE);
|
||||
}
|
||||
assert type != null;
|
||||
if (JetStandardLibrary.getInstance().isArray(type)) {
|
||||
if (KotlinBuiltIns.getInstance().isArray(type)) {
|
||||
JetType elementType = type.getArguments().get(0).getType();
|
||||
Type notBoxed = asmType(elementType);
|
||||
return StackValue.arrayElement(notBoxed, true);
|
||||
|
||||
@@ -53,7 +53,6 @@ import org.jetbrains.jet.lang.resolve.java.kt.DescriptorKindUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
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.*;
|
||||
@@ -361,7 +360,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
if (superClassType == null) {
|
||||
if (descriptor.getKind() == ClassKind.ENUM_CLASS) {
|
||||
superClassType = JetStandardLibrary.getInstance().getEnumType(descriptor.getDefaultType());
|
||||
superClassType = KotlinBuiltIns.getInstance().getEnumType(descriptor.getDefaultType());
|
||||
superClassAsmType = typeMapper.mapType(superClassType);
|
||||
}
|
||||
if (descriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
||||
@@ -413,7 +412,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
private void generateFunctionsForDataClasses() {
|
||||
if (!JetStandardLibrary.isData(descriptor)) return;
|
||||
if (!KotlinBuiltIns.getInstance().isData(descriptor)) return;
|
||||
|
||||
generateComponentFunctionsForDataClasses();
|
||||
|
||||
@@ -426,21 +425,21 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
private void generateDataClassToStringIfNeeded(List<PropertyDescriptor> properties) {
|
||||
ClassDescriptor stringClass = JetStandardLibrary.getInstance().getString();
|
||||
ClassDescriptor stringClass = KotlinBuiltIns.getInstance().getString();
|
||||
if (getDeclaredFunctionByRawSignature(descriptor, Name.identifier("toString"), stringClass) == null) {
|
||||
generateDataClassToStringMethod(properties);
|
||||
}
|
||||
}
|
||||
|
||||
private void generateDataClassHashCodeIfNeeded(List<PropertyDescriptor> properties) {
|
||||
ClassDescriptor intClass = JetStandardLibrary.getInstance().getInt();
|
||||
ClassDescriptor intClass = KotlinBuiltIns.getInstance().getInt();
|
||||
if (getDeclaredFunctionByRawSignature(descriptor, Name.identifier("hashCode"), intClass) == null) {
|
||||
generateDataClassHashCodeMethod(properties);
|
||||
}
|
||||
}
|
||||
|
||||
private void generateDataClassEqualsIfNeeded(List<PropertyDescriptor> properties) {
|
||||
ClassDescriptor booleanClass = JetStandardLibrary.getInstance().getBoolean();
|
||||
ClassDescriptor booleanClass = KotlinBuiltIns.getInstance().getBoolean();
|
||||
ClassDescriptor anyClass = KotlinBuiltIns.getInstance().getAny();
|
||||
FunctionDescriptor equalsFunction = getDeclaredFunctionByRawSignature(descriptor, Name.identifier("equals"), booleanClass, anyClass);
|
||||
if (equalsFunction == null) {
|
||||
@@ -605,7 +604,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
private void generateComponentFunctionsForDataClasses() {
|
||||
if (!myClass.hasPrimaryConstructor() || !JetStandardLibrary.isData(descriptor)) return;
|
||||
if (!myClass.hasPrimaryConstructor() || !KotlinBuiltIns.getInstance().isData(descriptor)) return;
|
||||
|
||||
ConstructorDescriptor constructor = descriptor.getConstructors().iterator().next();
|
||||
|
||||
@@ -646,7 +645,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (myEnumConstants.size() > 0) {
|
||||
{
|
||||
Type type =
|
||||
typeMapper.mapType(JetStandardLibrary.getInstance().getArrayType(descriptor.getDefaultType()),
|
||||
typeMapper.mapType(KotlinBuiltIns.getInstance().getArrayType(descriptor.getDefaultType()),
|
||||
JetTypeMapperMode.IMPL);
|
||||
|
||||
MethodVisitor mv =
|
||||
@@ -1398,7 +1397,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
Type myAsmType = typeMapper.mapType(myType, JetTypeMapperMode.IMPL);
|
||||
|
||||
assert myEnumConstants.size() > 0;
|
||||
JetType arrayType = JetStandardLibrary.getInstance().getArrayType(myType);
|
||||
JetType arrayType = KotlinBuiltIns.getInstance().getArrayType(myType);
|
||||
Type arrayAsmType = typeMapper.mapType(arrayType, JetTypeMapperMode.IMPL);
|
||||
v.newField(myClass, ACC_PRIVATE | ACC_STATIC | ACC_FINAL | ACC_SYNTHETIC, "$VALUES", arrayAsmType.getDescriptor(), null, null);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.lang.resolve.java.kt.DescriptorKindUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.*;
|
||||
@@ -115,7 +115,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
modifiers |= ACC_FINAL;
|
||||
}
|
||||
modifiers |= getDeprecatedAccessFlag(propertyDescriptor);
|
||||
if (JetStandardLibrary.getInstance().isVolatile(propertyDescriptor)) {
|
||||
if (KotlinBuiltIns.getInstance().isVolatile(propertyDescriptor)) {
|
||||
modifiers |= ACC_VOLATILE;
|
||||
}
|
||||
Type type = typeMapper.mapType(propertyDescriptor);
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
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;
|
||||
|
||||
@@ -34,20 +34,20 @@ import static org.jetbrains.jet.codegen.AsmUtil.isPrimitiveNumberClassDescriptor
|
||||
*/
|
||||
public class RangeCodegenUtil {
|
||||
private static final ImmutableMap<String, JetType> RANGE_TO_ELEMENT_TYPE = ImmutableMap.<String, JetType>builder()
|
||||
.put("ByteRange", JetStandardLibrary.getInstance().getByteType())
|
||||
.put("ShortRange", JetStandardLibrary.getInstance().getShortType())
|
||||
.put("IntRange", JetStandardLibrary.getInstance().getIntType())
|
||||
.put("LongRange", JetStandardLibrary.getInstance().getLongType())
|
||||
.put("FloatRange", JetStandardLibrary.getInstance().getFloatType())
|
||||
.put("DoubleRange", JetStandardLibrary.getInstance().getDoubleType())
|
||||
.put("CharRange", JetStandardLibrary.getInstance().getCharType())
|
||||
.put("ByteRange", KotlinBuiltIns.getInstance().getByteType())
|
||||
.put("ShortRange", KotlinBuiltIns.getInstance().getShortType())
|
||||
.put("IntRange", KotlinBuiltIns.getInstance().getIntType())
|
||||
.put("LongRange", KotlinBuiltIns.getInstance().getLongType())
|
||||
.put("FloatRange", KotlinBuiltIns.getInstance().getFloatType())
|
||||
.put("DoubleRange", KotlinBuiltIns.getInstance().getDoubleType())
|
||||
.put("CharRange", KotlinBuiltIns.getInstance().getCharType())
|
||||
.build();
|
||||
|
||||
private RangeCodegenUtil() {}
|
||||
|
||||
public static boolean isIntRange(JetType rangeType) {
|
||||
return !rangeType.isNullable()
|
||||
&& JetStandardLibrary.getInstance().getIntType().equals(getPrimitiveRangeElementType(rangeType));
|
||||
&& KotlinBuiltIns.getInstance().getIntType().equals(getPrimitiveRangeElementType(rangeType));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -84,7 +84,7 @@ public class RangeCodegenUtil {
|
||||
public static JetType getPrimitiveRangeElementType(JetType rangeType) {
|
||||
ClassifierDescriptor declarationDescriptor = rangeType.getConstructor().getDeclarationDescriptor();
|
||||
assert declarationDescriptor != null;
|
||||
if (declarationDescriptor != JetStandardLibrary.getInstance().getLibraryScope().getClassifier(declarationDescriptor.getName())) {
|
||||
if (declarationDescriptor != KotlinBuiltIns.getInstance().getBuiltInsScope().getClassifier(declarationDescriptor.getName())) {
|
||||
// Must be a standard library class
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.PrimitiveType;
|
||||
|
||||
import java.util.List;
|
||||
@@ -56,14 +56,14 @@ public class ArrayIterator implements IntrinsicMethod {
|
||||
.get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) call.getCalleeExpression());
|
||||
assert funDescriptor != null;
|
||||
ClassDescriptor containingDeclaration = (ClassDescriptor) funDescriptor.getContainingDeclaration().getOriginal();
|
||||
if (containingDeclaration.equals(JetStandardLibrary.getInstance().getArray())) {
|
||||
if (containingDeclaration.equals(KotlinBuiltIns.getInstance().getArray())) {
|
||||
v.invokestatic("jet/runtime/ArrayIterator", "iterator", "([Ljava/lang/Object;)Ljava/util/Iterator;");
|
||||
return StackValue.onStack(AsmTypeConstants.JET_ITERATOR_TYPE);
|
||||
}
|
||||
else {
|
||||
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
|
||||
PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
|
||||
ClassDescriptor arrayClass = JetStandardLibrary.getInstance().getPrimitiveArrayClassDescriptor(primitiveType);
|
||||
ClassDescriptor arrayClass = KotlinBuiltIns.getInstance().getPrimitiveArrayClassDescriptor(primitiveType);
|
||||
if (containingDeclaration.equals(arrayClass)) {
|
||||
String methodSignature = "([" + jvmPrimitiveType.getJvmLetter() + ")" + jvmPrimitiveType.getIterator().getDescriptor();
|
||||
v.invokestatic("jet/runtime/ArrayIterator", "iterator", methodSignature);
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -269,7 +268,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
return asmType;
|
||||
}
|
||||
|
||||
if (mapBuiltinsToJava && descriptor instanceof ClassDescriptor && JetStandardLibrary.getInstance().isArray(jetType)) {
|
||||
if (mapBuiltinsToJava && descriptor instanceof ClassDescriptor && KotlinBuiltIns.getInstance().isArray(jetType)) {
|
||||
if (jetType.getArguments().size() != 1) {
|
||||
throw new UnsupportedOperationException("arrays must have one type argument");
|
||||
}
|
||||
@@ -768,10 +767,10 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
if (containingDeclaration.getKind() == ClassKind.ENUM_CLASS || containingDeclaration.getKind() == ClassKind.ENUM_ENTRY) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.ENUM_NAME);
|
||||
mapType(JetStandardLibrary.getInstance().getStringType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
mapType(KotlinBuiltIns.getInstance().getStringType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.ENUM_ORDINAL);
|
||||
mapType(JetStandardLibrary.getInstance().getIntType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
mapType(KotlinBuiltIns.getInstance().getIntType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
@@ -870,7 +869,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
|
||||
private static boolean isGenericsArray(JetType type) {
|
||||
return JetStandardLibrary.getInstance().isArray(type) &&
|
||||
return KotlinBuiltIns.getInstance().isArray(type) &&
|
||||
type.getArguments().get(0).getType().getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.jetbrains.jet.lang.parsing.JetParserDefinition;
|
||||
import org.jetbrains.jet.lang.parsing.JetScriptDefinitionProvider;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.java.JetFilesProvider;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.plugin.JetFileType;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
|
||||
@@ -102,7 +102,7 @@ public class JetCoreEnvironment {
|
||||
|
||||
JetScriptDefinitionProvider.getInstance(project).addScriptDefinitions(configuration.getList(CommonConfigurationKeys.SCRIPT_DEFINITIONS_KEY));
|
||||
|
||||
JetStandardLibrary.initialize(project);
|
||||
KotlinBuiltIns.initialize(project);
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -124,7 +124,7 @@ public enum AnalyzerFacadeForJVM implements AnalyzerFacade {
|
||||
) {
|
||||
FqName fqName = DescriptorUtils.getFQName(namespaceDescriptor).toSafe();
|
||||
if (new FqName("jet").equals(fqName)) {
|
||||
namespaceMemberScope.importScope(JetStandardLibrary.getInstance().getLibraryScope());
|
||||
namespaceMemberScope.importScope(KotlinBuiltIns.getInstance().getBuiltInsScope());
|
||||
}
|
||||
if (psiClassFinder.findPsiPackage(fqName) != null) {
|
||||
JavaPackageScope javaPackageScope = javaDescriptorResolver.getJavaPackageScope(fqName, namespaceDescriptor);
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -89,7 +89,7 @@ public class JavaSemanticServices {
|
||||
@Nullable
|
||||
public ClassDescriptor getKotlinBuiltinClassDescriptor(@NotNull FqName qualifiedName) {
|
||||
if (qualifiedName.firstSegmentIs(Name.identifier("jet")) && qualifiedName.pathSegments().size() == 2) {
|
||||
return (ClassDescriptor) JetStandardLibrary.getInstance().getLibraryScope().getClassifier(qualifiedName.pathSegments().get(1));
|
||||
return (ClassDescriptor) KotlinBuiltIns.getInstance().getBuiltInsScope().getClassifier(qualifiedName.pathSegments().get(1));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
|
||||
+5
-6
@@ -27,7 +27,6 @@ import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.PrimitiveType;
|
||||
|
||||
import java.util.*;
|
||||
@@ -57,17 +56,17 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
|
||||
}
|
||||
|
||||
private void initPrimitives() {
|
||||
JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
|
||||
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
|
||||
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
|
||||
PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
|
||||
register(jvmPrimitiveType.getWrapper().getFqName(), standardLibrary.getPrimitiveClassDescriptor(primitiveType));
|
||||
register(jvmPrimitiveType.getWrapper().getFqName(), builtIns.getPrimitiveClassDescriptor(primitiveType));
|
||||
}
|
||||
|
||||
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
|
||||
PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
|
||||
primitiveTypesMap.put(jvmPrimitiveType.getName(), JetStandardLibrary.getInstance().getPrimitiveJetType(primitiveType));
|
||||
primitiveTypesMap.put("[" + jvmPrimitiveType.getName(), JetStandardLibrary.getInstance().getPrimitiveArrayJetType(primitiveType));
|
||||
primitiveTypesMap.put(jvmPrimitiveType.getWrapper().getFqName().getFqName(), JetStandardLibrary.getInstance().getNullablePrimitiveJetType(
|
||||
primitiveTypesMap.put(jvmPrimitiveType.getName(), KotlinBuiltIns.getInstance().getPrimitiveJetType(primitiveType));
|
||||
primitiveTypesMap.put("[" + jvmPrimitiveType.getName(), KotlinBuiltIns.getInstance().getPrimitiveArrayJetType(primitiveType));
|
||||
primitiveTypesMap.put(jvmPrimitiveType.getWrapper().getFqName().getFqName(), KotlinBuiltIns.getInstance().getNullablePrimitiveJetType(
|
||||
primitiveType));
|
||||
}
|
||||
primitiveTypesMap.put("void", KotlinBuiltIns.getInstance().getUnitType());
|
||||
|
||||
+16
-17
@@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.resolve.java;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.*;
|
||||
@@ -30,25 +29,25 @@ import java.util.*;
|
||||
public abstract class JavaToKotlinClassMapBuilder {
|
||||
|
||||
/*package*/ void init() {
|
||||
JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
|
||||
KotlinBuiltIns kotlinBuiltIns = KotlinBuiltIns.getInstance();
|
||||
|
||||
register(Object.class, KotlinBuiltIns.getInstance().getAny());
|
||||
register(String.class, standardLibrary.getString());
|
||||
register(CharSequence.class, standardLibrary.getCharSequence());
|
||||
register(Throwable.class, standardLibrary.getThrowable());
|
||||
register(Number.class, standardLibrary.getNumber());
|
||||
register(Comparable.class, standardLibrary.getComparable());
|
||||
register(Enum.class, standardLibrary.getEnum());
|
||||
register(Annotation.class, standardLibrary.getAnnotation());
|
||||
register(String.class, kotlinBuiltIns.getString());
|
||||
register(CharSequence.class, kotlinBuiltIns.getCharSequence());
|
||||
register(Throwable.class, kotlinBuiltIns.getThrowable());
|
||||
register(Number.class, kotlinBuiltIns.getNumber());
|
||||
register(Comparable.class, kotlinBuiltIns.getComparable());
|
||||
register(Enum.class, kotlinBuiltIns.getEnum());
|
||||
register(Annotation.class, kotlinBuiltIns.getAnnotation());
|
||||
|
||||
register(Iterable.class, standardLibrary.getIterable(), standardLibrary.getMutableIterable());
|
||||
register(Iterator.class, standardLibrary.getIterator(), standardLibrary.getMutableIterator());
|
||||
register(Collection.class, standardLibrary.getCollection(), standardLibrary.getMutableCollection());
|
||||
register(List.class, standardLibrary.getList(), standardLibrary.getMutableList());
|
||||
register(Set.class, standardLibrary.getSet(), standardLibrary.getMutableSet());
|
||||
register(Map.class, standardLibrary.getMap(), standardLibrary.getMutableMap());
|
||||
register(Map.Entry.class, standardLibrary.getMapEntry(), standardLibrary.getMutableMapEntry());
|
||||
register(ListIterator.class, standardLibrary.getListIterator(), standardLibrary.getMutableListIterator());
|
||||
register(Iterable.class, kotlinBuiltIns.getIterable(), kotlinBuiltIns.getMutableIterable());
|
||||
register(Iterator.class, kotlinBuiltIns.getIterator(), kotlinBuiltIns.getMutableIterator());
|
||||
register(Collection.class, kotlinBuiltIns.getCollection(), kotlinBuiltIns.getMutableCollection());
|
||||
register(List.class, kotlinBuiltIns.getList(), kotlinBuiltIns.getMutableList());
|
||||
register(Set.class, kotlinBuiltIns.getSet(), kotlinBuiltIns.getMutableSet());
|
||||
register(Map.class, kotlinBuiltIns.getMap(), kotlinBuiltIns.getMutableMap());
|
||||
register(Map.Entry.class, kotlinBuiltIns.getMapEntry(), kotlinBuiltIns.getMutableMapEntry());
|
||||
register(ListIterator.class, kotlinBuiltIns.getListIterator(), kotlinBuiltIns.getMutableListIterator());
|
||||
}
|
||||
|
||||
/*package*/ abstract void register(@NotNull Class<?> javaClass, @NotNull ClassDescriptor kotlinDescriptor);
|
||||
|
||||
+3
-3
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
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.rt.signature.JetSignatureReader;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -87,7 +87,7 @@ public class JavaTypeTransformer {
|
||||
@NotNull
|
||||
public JetType transformToType(@NotNull String kotlinSignature, TypeVariableResolver typeVariableResolver) {
|
||||
final JetType[] r = new JetType[1];
|
||||
JetTypeJetSignatureReader reader = new JetTypeJetSignatureReader(javaSemanticServices, JetStandardLibrary.getInstance(), typeVariableResolver) {
|
||||
JetTypeJetSignatureReader reader = new JetTypeJetSignatureReader(javaSemanticServices, KotlinBuiltIns.getInstance(), typeVariableResolver) {
|
||||
@Override
|
||||
protected void done(@NotNull JetType jetType) {
|
||||
r[0] = jetType;
|
||||
@@ -218,7 +218,7 @@ public class JavaTypeTransformer {
|
||||
}
|
||||
|
||||
JetType type = transformToType(componentType, typeVariableResolver);
|
||||
return TypeUtils.makeNullable(JetStandardLibrary.getInstance().getArrayType(variance, type));
|
||||
return TypeUtils.makeNullable(KotlinBuiltIns.getInstance().getArrayType(variance, type));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
-11
@@ -24,7 +24,6 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureExceptionsAdapter;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureVariance;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureVisitor;
|
||||
@@ -42,13 +41,13 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
|
||||
|
||||
private final JavaSemanticServices javaSemanticServices;
|
||||
private final JavaDescriptorResolver javaDescriptorResolver;
|
||||
private final JetStandardLibrary jetStandardLibrary;
|
||||
private final KotlinBuiltIns kotlinBuiltIns;
|
||||
private final TypeVariableResolver typeVariableResolver;
|
||||
|
||||
public JetTypeJetSignatureReader(JavaSemanticServices javaSemanticServices, JetStandardLibrary jetStandardLibrary, TypeVariableResolver typeVariableResolver) {
|
||||
public JetTypeJetSignatureReader(JavaSemanticServices javaSemanticServices, KotlinBuiltIns kotlinBuiltIns, TypeVariableResolver typeVariableResolver) {
|
||||
this.javaSemanticServices = javaSemanticServices;
|
||||
this.javaDescriptorResolver = javaSemanticServices.getDescriptorResolver();
|
||||
this.jetStandardLibrary = jetStandardLibrary;
|
||||
this.kotlinBuiltIns = kotlinBuiltIns;
|
||||
this.typeVariableResolver = typeVariableResolver;
|
||||
}
|
||||
|
||||
@@ -57,7 +56,7 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
|
||||
if (!nullable) {
|
||||
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
|
||||
if (jvmPrimitiveType.getJvmLetter() == descriptor) {
|
||||
return jetStandardLibrary.getPrimitiveJetType(jvmPrimitiveType.getPrimitiveType());
|
||||
return KotlinBuiltIns.getInstance().getPrimitiveJetType(jvmPrimitiveType.getPrimitiveType());
|
||||
}
|
||||
}
|
||||
if (descriptor == 'V') {
|
||||
@@ -67,7 +66,7 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
|
||||
else {
|
||||
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
|
||||
if (jvmPrimitiveType.getJvmLetter() == descriptor) {
|
||||
return jetStandardLibrary.getNullablePrimitiveJetType(jvmPrimitiveType.getPrimitiveType());
|
||||
return KotlinBuiltIns.getInstance().getNullablePrimitiveJetType(jvmPrimitiveType.getPrimitiveType());
|
||||
}
|
||||
}
|
||||
if (descriptor == 'V') {
|
||||
@@ -152,7 +151,7 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitTypeArgument(final JetSignatureVariance variance) {
|
||||
return new JetTypeJetSignatureReader(javaSemanticServices, jetStandardLibrary, typeVariableResolver) {
|
||||
return new JetTypeJetSignatureReader(javaSemanticServices, kotlinBuiltIns, typeVariableResolver) {
|
||||
|
||||
@Override
|
||||
protected void done(@NotNull JetType jetType) {
|
||||
@@ -163,23 +162,23 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitArrayType(final boolean nullable) {
|
||||
return new JetTypeJetSignatureReader(javaSemanticServices, jetStandardLibrary, typeVariableResolver) {
|
||||
return new JetTypeJetSignatureReader(javaSemanticServices, kotlinBuiltIns, typeVariableResolver) {
|
||||
@Override
|
||||
public void visitBaseType(char descriptor, boolean nullable) {
|
||||
JetType primitiveType = getPrimitiveType(descriptor, nullable);
|
||||
JetType arrayType;
|
||||
if (!nullable) {
|
||||
arrayType = jetStandardLibrary.getPrimitiveArrayJetTypeByPrimitiveJetType(primitiveType);
|
||||
arrayType = KotlinBuiltIns.getInstance().getPrimitiveArrayJetTypeByPrimitiveJetType(primitiveType);
|
||||
}
|
||||
else {
|
||||
arrayType = TypeUtils.makeNullableAsSpecified(jetStandardLibrary.getArrayType(primitiveType), nullable);
|
||||
arrayType = TypeUtils.makeNullableAsSpecified(KotlinBuiltIns.getInstance().getArrayType(primitiveType), nullable);
|
||||
}
|
||||
JetTypeJetSignatureReader.this.done(arrayType);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done(@NotNull JetType jetType) {
|
||||
JetType arrayType = TypeUtils.makeNullableAsSpecified(jetStandardLibrary.getArrayType(jetType), nullable);
|
||||
JetType arrayType = TypeUtils.makeNullableAsSpecified(KotlinBuiltIns.getInstance().getArrayType(jetType), nullable);
|
||||
JetTypeJetSignatureReader.this.done(arrayType);
|
||||
}
|
||||
};
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.wrapper.PsiMethodWrapper;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
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.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -152,7 +152,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
|
||||
alternativeVarargElementType = TypeTransformingVisitor.computeType(alternativeTypeElement, originalParamVarargElementType,
|
||||
originalToAltTypeParameters);
|
||||
alternativeType = JetStandardLibrary.getInstance().getArrayType(alternativeVarargElementType);
|
||||
alternativeType = KotlinBuiltIns.getInstance().getArrayType(alternativeVarargElementType);
|
||||
}
|
||||
|
||||
altParamDescriptors.add(new ValueParameterDescriptorImpl(
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
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 javax.inject.Inject;
|
||||
import java.util.*;
|
||||
@@ -305,7 +305,7 @@ public final class JavaFunctionResolver {
|
||||
private static boolean isEnumSpecialMethod(@NotNull FunctionDescriptor functionDescriptor) {
|
||||
List<ValueParameterDescriptor> methodTypeParameters = functionDescriptor.getValueParameters();
|
||||
String methodName = functionDescriptor.getName().getName();
|
||||
JetType nullableString = TypeUtils.makeNullable(JetStandardLibrary.getInstance().getStringType());
|
||||
JetType nullableString = TypeUtils.makeNullable(KotlinBuiltIns.getInstance().getStringType());
|
||||
if (methodName.equals("valueOf") && methodTypeParameters.size() == 1
|
||||
&& JetTypeChecker.INSTANCE.isSubtypeOf(methodTypeParameters.get(0).getType(), nullableString)) {
|
||||
return true;
|
||||
|
||||
+2
-3
@@ -32,7 +32,6 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureAdapter;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureExceptionsAdapter;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureReader;
|
||||
@@ -141,7 +140,7 @@ public final class JavaSignatureResolver {
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitClassBound() {
|
||||
return new JetTypeJetSignatureReader(semanticServices, JetStandardLibrary.getInstance(), typeVariableResolver) {
|
||||
return new JetTypeJetSignatureReader(semanticServices, KotlinBuiltIns.getInstance(), typeVariableResolver) {
|
||||
@Override
|
||||
protected void done(@NotNull JetType jetType) {
|
||||
if (isJavaLangObject(jetType)) {
|
||||
@@ -154,7 +153,7 @@ public final class JavaSignatureResolver {
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitInterfaceBound() {
|
||||
return new JetTypeJetSignatureReader(semanticServices, JetStandardLibrary.getInstance(), typeVariableResolver) {
|
||||
return new JetTypeJetSignatureReader(semanticServices, KotlinBuiltIns.getInstance(), typeVariableResolver) {
|
||||
@Override
|
||||
protected void done(@NotNull JetType jetType) {
|
||||
upperBounds.add(jetType);
|
||||
|
||||
+1
-2
@@ -33,7 +33,6 @@ import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureAdapter;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureExceptionsAdapter;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureReader;
|
||||
@@ -119,7 +118,7 @@ public final class JavaSupertypesResolver {
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitSuperclass() {
|
||||
return new JetTypeJetSignatureReader(semanticServices, JetStandardLibrary.getInstance(),
|
||||
return new JetTypeJetSignatureReader(semanticServices, KotlinBuiltIns.getInstance(),
|
||||
typeVariableResolver) {
|
||||
@Override
|
||||
protected void done(@NotNull JetType jetType) {
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ import org.jetbrains.jet.lang.resolve.java.wrapper.PsiParameterWrapper;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
@@ -80,7 +80,7 @@ public final class JavaValueParameterResolver {
|
||||
|
||||
JetType varargElementType;
|
||||
if (psiType instanceof PsiEllipsisType) {
|
||||
varargElementType = JetStandardLibrary.getInstance().getArrayElementType(TypeUtils.makeNotNullable(outType));
|
||||
varargElementType = KotlinBuiltIns.getInstance().getArrayElementType(TypeUtils.makeNotNullable(outType));
|
||||
outType = TypeUtils.makeNotNullable(outType);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -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(),
|
||||
|
||||
+8
-8
@@ -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
|
||||
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
|
||||
+14
-16
@@ -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;
|
||||
|
||||
+8
-9
@@ -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
|
||||
|
||||
+2
-3
@@ -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);
|
||||
|
||||
+6
-7
@@ -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();
|
||||
|
||||
+2
-3
@@ -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));
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorResolver;
|
||||
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices;
|
||||
import org.jetbrains.jet.lang.resolve.TypeResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.ModuleConfiguration;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.jet.lang.resolve.AnnotationResolver;
|
||||
@@ -37,7 +37,7 @@ public class InjectorForTests {
|
||||
private ExpressionTypingServices expressionTypingServices;
|
||||
private TypeResolver typeResolver;
|
||||
private CallResolver callResolver;
|
||||
private JetStandardLibrary jetStandardLibrary;
|
||||
private KotlinBuiltIns kotlinBuiltIns;
|
||||
private ModuleConfiguration moduleConfiguration;
|
||||
private final Project project;
|
||||
private AnnotationResolver annotationResolver;
|
||||
@@ -51,7 +51,7 @@ public class InjectorForTests {
|
||||
this.expressionTypingServices = new ExpressionTypingServices();
|
||||
this.typeResolver = new TypeResolver();
|
||||
this.callResolver = new CallResolver();
|
||||
this.jetStandardLibrary = JetStandardLibrary.getInstance();
|
||||
this.kotlinBuiltIns = KotlinBuiltIns.getInstance();
|
||||
this.moduleConfiguration = ModuleConfiguration.EMPTY;
|
||||
this.project = project;
|
||||
this.annotationResolver = new AnnotationResolver();
|
||||
@@ -102,8 +102,8 @@ public class InjectorForTests {
|
||||
return this.callResolver;
|
||||
}
|
||||
|
||||
public JetStandardLibrary getJetStandardLibrary() {
|
||||
return this.jetStandardLibrary;
|
||||
public KotlinBuiltIns getKotlinBuiltIns() {
|
||||
return this.kotlinBuiltIns;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
|
||||
+4
-4
@@ -35,7 +35,7 @@ import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
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.resolve.DescriptorRenderer;
|
||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
@@ -283,7 +283,7 @@ public class AnnotationJavaDescriptorResolverTest extends TestCaseWithTmpdir {
|
||||
|
||||
private static void checkSimpleCompileTimeConstant(@NotNull CompileTimeConstant<?> actual, @NotNull String expectedType, @NotNull String expectedValue) {
|
||||
assertEquals(expectedValue, actual.toString());
|
||||
compareJetTypeWithClass(actual.getType(JetStandardLibrary.getInstance()), expectedType);
|
||||
compareJetTypeWithClass(actual.getType(KotlinBuiltIns.getInstance()), expectedType);
|
||||
}
|
||||
|
||||
private void checkAnnotationCompileTimeConstant(
|
||||
@@ -293,7 +293,7 @@ public class AnnotationJavaDescriptorResolverTest extends TestCaseWithTmpdir {
|
||||
@NotNull String expectedParameterType,
|
||||
@NotNull String expectedParameterValue
|
||||
) {
|
||||
compareJetTypeWithClass(actual.getType(JetStandardLibrary.getInstance()), expectedType);
|
||||
compareJetTypeWithClass(actual.getType(KotlinBuiltIns.getInstance()), expectedType);
|
||||
CompileTimeConstant<?> innerAnnotation = getCompileTimeConstant(actual.getValue(), expectedType, parameterName);
|
||||
checkSimpleCompileTimeConstant(innerAnnotation, expectedParameterType, expectedParameterValue);
|
||||
}
|
||||
@@ -304,7 +304,7 @@ public class AnnotationJavaDescriptorResolverTest extends TestCaseWithTmpdir {
|
||||
@NotNull String expectedArgumentType,
|
||||
@NotNull String[] expectedValues
|
||||
) {
|
||||
JetType actualType = actual.getType(JetStandardLibrary.getInstance());
|
||||
JetType actualType = actual.getType(KotlinBuiltIns.getInstance());
|
||||
compareJetTypeWithClass(actualType, expectedType);
|
||||
|
||||
List<CompileTimeConstant<?>> arrayValuesCompileTimeConst = actual.getValue();
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
@@ -84,7 +84,7 @@ public class LazyResolveBuiltinClassesTest extends KotlinTestWithEnvironment {
|
||||
Predicates.in(Sets.newHashSet(new FqNameUnsafe("jet.Any"), new FqNameUnsafe("jet.Nothing"))));
|
||||
|
||||
NamespaceDescriptor jetNamespaceFromJSL =
|
||||
(NamespaceDescriptor) JetStandardLibrary.getInstance().getInt().getContainingDeclaration();
|
||||
(NamespaceDescriptor) KotlinBuiltIns.getInstance().getInt().getContainingDeclaration();
|
||||
NamespaceDescriptor jetNamespaceFromLazy = lazyModule.getRootNamespace().getMemberScope().getNamespace(
|
||||
jetNamespaceFromJSL.getName());
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.jetbrains.jet.lang.resolve.java.scope.JavaPackageScope;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -107,7 +107,7 @@ public class LazyResolveTestUtil {
|
||||
) {
|
||||
FqName fqName = DescriptorUtils.getFQName(namespaceDescriptor).toSafe();
|
||||
if (new FqName("jet").equals(fqName)) {
|
||||
namespaceMemberScope.importScope(JetStandardLibrary.getInstance().getLibraryScope());
|
||||
namespaceMemberScope.importScope(KotlinBuiltIns.getInstance().getBuiltInsScope());
|
||||
}
|
||||
if (psiClassFinder.findPsiPackage(fqName) != null) {
|
||||
JavaPackageScope javaPackageScope = javaDescriptorResolver.getJavaPackageScope(fqName, namespaceDescriptor);
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeConstructor;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -153,7 +153,7 @@ public abstract class ExpectedResolveData {
|
||||
}
|
||||
final Set<PsiElement> unresolvedReferences = Sets.newHashSet();
|
||||
Project project = files.iterator().next().getProject();
|
||||
JetStandardLibrary lib = JetStandardLibrary.getInstance();
|
||||
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
|
||||
|
||||
AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(project, files,
|
||||
Collections.<AnalyzerScriptParameter>emptyList(), Predicates.<PsiFile>alwaysTrue(), BuiltinsScopeExtensionMode.ALL);
|
||||
@@ -259,7 +259,7 @@ public abstract class ExpectedResolveData {
|
||||
|
||||
JetType actualType = bindingContext.get(BindingContext.TYPE, typeReference);
|
||||
assertNotNull("Type " + name + " not resolved for reference " + name, actualType);
|
||||
ClassifierDescriptor expectedClass = lib.getLibraryScope().getClassifier(Name.identifier(name.substring(STANDARD_PREFIX.length())));
|
||||
ClassifierDescriptor expectedClass = builtIns.getBuiltInsScope().getClassifier(Name.identifier(name.substring(STANDARD_PREFIX.length())));
|
||||
assertNotNull("Expected class not found: " + name);
|
||||
assertSame("Type resolution mismatch: ", expectedClass.getTypeConstructor(), actualType.getConstructor());
|
||||
continue;
|
||||
@@ -317,7 +317,7 @@ public abstract class ExpectedResolveData {
|
||||
TypeConstructor expectedTypeConstructor;
|
||||
if (typeName.startsWith(STANDARD_PREFIX)) {
|
||||
String name = typeName.substring(STANDARD_PREFIX.length());
|
||||
ClassifierDescriptor expectedClass = lib.getLibraryScope().getClassifier(Name.identifier(name));
|
||||
ClassifierDescriptor expectedClass = builtIns.getBuiltInsScope().getClassifier(Name.identifier(name));
|
||||
|
||||
assertNotNull("Expected class not found: " + typeName, expectedClass);
|
||||
expectedTypeConstructor = expectedClass.getTypeConstructor();
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeProjection;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
|
||||
import java.io.File;
|
||||
@@ -68,14 +68,14 @@ public class JetResolveTest extends ExtensibleResolveTestCase {
|
||||
@Override
|
||||
protected ExpectedResolveData getExpectedResolveData() {
|
||||
Project project = getProject();
|
||||
JetStandardLibrary lib = JetStandardLibrary.getInstance();
|
||||
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
|
||||
Map<String, DeclarationDescriptor> nameToDescriptor = new HashMap<String, DeclarationDescriptor>();
|
||||
nameToDescriptor.put("kotlin::Int.plus(Int)", standardFunction(lib.getInt(), "plus", lib.getIntType()));
|
||||
FunctionDescriptor descriptorForGet = standardFunction(lib.getArray(), Collections.singletonList(new TypeProjection(lib.getIntType())), "get", lib.getIntType());
|
||||
nameToDescriptor.put("kotlin::Int.plus(Int)", standardFunction(builtIns.getInt(), "plus", builtIns.getIntType()));
|
||||
FunctionDescriptor descriptorForGet = standardFunction(builtIns.getArray(), Collections.singletonList(new TypeProjection(builtIns.getIntType())), "get", builtIns.getIntType());
|
||||
nameToDescriptor.put("kotlin::Array.get(Int)", descriptorForGet.getOriginal());
|
||||
nameToDescriptor.put("kotlin::Int.compareTo(Double)", standardFunction(lib.getInt(), "compareTo", lib.getDoubleType()));
|
||||
nameToDescriptor.put("kotlin::Int.compareTo(Double)", standardFunction(builtIns.getInt(), "compareTo", builtIns.getDoubleType()));
|
||||
@NotNull
|
||||
FunctionDescriptor descriptorForSet = standardFunction(lib.getArray(), Collections.singletonList(new TypeProjection(lib.getIntType())), "set", lib.getIntType(), lib.getIntType());
|
||||
FunctionDescriptor descriptorForSet = standardFunction(builtIns.getArray(), Collections.singletonList(new TypeProjection(builtIns.getIntType())), "set", builtIns.getIntType(), builtIns.getIntType());
|
||||
nameToDescriptor.put("kotlin::Array.set(Int, Int)", descriptorForSet.getOriginal());
|
||||
|
||||
Map<String, PsiElement> nameToDeclaration = new HashMap<String, PsiElement>();
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -63,9 +63,9 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
|
||||
public void setUp() throws Exception {
|
||||
InjectorForTests injector = new InjectorForTests(getProject());
|
||||
JetStandardLibrary library = injector.getJetStandardLibrary();
|
||||
KotlinBuiltIns builtIns = injector.getKotlinBuiltIns();
|
||||
descriptorResolver = injector.getDescriptorResolver();
|
||||
scope = createScope(library.getLibraryScope());
|
||||
scope = createScope(builtIns.getBuiltInsScope());
|
||||
}
|
||||
|
||||
private JetScope createScope(JetScope libraryScope) {
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.OverloadUtil;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
public class JetOverloadTest extends JetLiteFixture {
|
||||
|
||||
private ModuleDescriptor root = new ModuleDescriptor(Name.special("<test_root>"));
|
||||
private JetStandardLibrary library;
|
||||
private KotlinBuiltIns builtIns;
|
||||
private DescriptorResolver descriptorResolver;
|
||||
|
||||
@Override
|
||||
@@ -49,7 +49,7 @@ public class JetOverloadTest extends JetLiteFixture {
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
InjectorForTests injector = new InjectorForTests(getProject());
|
||||
library = injector.getJetStandardLibrary();
|
||||
builtIns = injector.getKotlinBuiltIns();
|
||||
descriptorResolver = injector.getDescriptorResolver();
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public class JetOverloadTest extends JetLiteFixture {
|
||||
|
||||
private FunctionDescriptor makeFunction(String funDecl) {
|
||||
JetNamedFunction function = JetPsiFactory.createFunction(getProject(), funDecl);
|
||||
return descriptorResolver.resolveFunctionDescriptor(root, library.getLibraryScope(), function, JetTestUtils.DUMMY_TRACE);
|
||||
return descriptorResolver.resolveFunctionDescriptor(root, builtIns.getBuiltInsScope(), function, JetTestUtils.DUMMY_TRACE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.OverridingUtil;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
public class JetOverridingTest extends JetLiteFixture {
|
||||
|
||||
private ModuleDescriptor root = new ModuleDescriptor(Name.special("<test_root>"));
|
||||
private JetStandardLibrary library;
|
||||
private KotlinBuiltIns builtIns;
|
||||
private DescriptorResolver descriptorResolver;
|
||||
|
||||
@Override
|
||||
@@ -49,7 +49,7 @@ public class JetOverridingTest extends JetLiteFixture {
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
InjectorForTests injector = new InjectorForTests(getProject());
|
||||
library = injector.getJetStandardLibrary();
|
||||
builtIns = injector.getKotlinBuiltIns();
|
||||
descriptorResolver = injector.getDescriptorResolver();
|
||||
}
|
||||
|
||||
@@ -168,6 +168,6 @@ public class JetOverridingTest extends JetLiteFixture {
|
||||
|
||||
private FunctionDescriptor makeFunction(String funDecl) {
|
||||
JetNamedFunction function = JetPsiFactory.createFunction(getProject(), funDecl);
|
||||
return descriptorResolver.resolveFunctionDescriptor(root, library.getLibraryScope(), function, JetTestUtils.DUMMY_TRACE);
|
||||
return descriptorResolver.resolveFunctionDescriptor(root, builtIns.getBuiltInsScope(), function, JetTestUtils.DUMMY_TRACE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
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 java.util.*;
|
||||
@@ -56,7 +55,7 @@ import java.util.*;
|
||||
*/
|
||||
public class JetTypeCheckerTest extends JetLiteFixture {
|
||||
|
||||
private JetStandardLibrary library;
|
||||
private KotlinBuiltIns builtIns;
|
||||
private ClassDefinitions classDefinitions;
|
||||
private DescriptorResolver descriptorResolver;
|
||||
private JetScope scopeWithImports;
|
||||
@@ -77,7 +76,7 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
library = JetStandardLibrary.getInstance();
|
||||
builtIns = KotlinBuiltIns.getInstance();
|
||||
classDefinitions = new ClassDefinitions();
|
||||
|
||||
InjectorForTests injector = new InjectorForTests(getProject());
|
||||
@@ -94,28 +93,28 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
||||
}
|
||||
|
||||
public void testConstants() throws Exception {
|
||||
assertType("1", library.getIntType());
|
||||
assertType("0x1", library.getIntType());
|
||||
assertType("0X1", library.getIntType());
|
||||
assertType("0b1", library.getIntType());
|
||||
assertType("0B1", library.getIntType());
|
||||
assertType("1", builtIns.getIntType());
|
||||
assertType("0x1", builtIns.getIntType());
|
||||
assertType("0X1", builtIns.getIntType());
|
||||
assertType("0b1", builtIns.getIntType());
|
||||
assertType("0B1", builtIns.getIntType());
|
||||
|
||||
assertType("1.toLong()", library.getLongType());
|
||||
assertType("1.toLong()", builtIns.getLongType());
|
||||
|
||||
assertType("1.0", library.getDoubleType());
|
||||
assertType("1.0.toDouble()", library.getDoubleType());
|
||||
assertType("0x1.fffffffffffffp1023", library.getDoubleType());
|
||||
assertType("1.0", builtIns.getDoubleType());
|
||||
assertType("1.0.toDouble()", builtIns.getDoubleType());
|
||||
assertType("0x1.fffffffffffffp1023", builtIns.getDoubleType());
|
||||
|
||||
assertType("1.0.toFloat()", library.getFloatType());
|
||||
assertType("0x1.fffffffffffffp1023.toFloat()", library.getFloatType());
|
||||
assertType("1.0.toFloat()", builtIns.getFloatType());
|
||||
assertType("0x1.fffffffffffffp1023.toFloat()", builtIns.getFloatType());
|
||||
|
||||
assertType("true", library.getBooleanType());
|
||||
assertType("false", library.getBooleanType());
|
||||
assertType("true", builtIns.getBooleanType());
|
||||
assertType("false", builtIns.getBooleanType());
|
||||
|
||||
assertType("'d'", library.getCharType());
|
||||
assertType("'d'", builtIns.getCharType());
|
||||
|
||||
assertType("\"d\"", library.getStringType());
|
||||
assertType("\"\"\"d\"\"\"", library.getStringType());
|
||||
assertType("\"d\"", builtIns.getStringType());
|
||||
assertType("\"\"\"d\"\"\"", builtIns.getStringType());
|
||||
|
||||
assertType("#()", KotlinBuiltIns.getInstance().getUnitType());
|
||||
|
||||
@@ -125,7 +124,7 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
||||
public void testTupleConstants() throws Exception {
|
||||
assertType("#()", KotlinBuiltIns.getInstance().getUnitType());
|
||||
|
||||
assertType("#(1, 'a')", KotlinBuiltIns.getInstance().getTupleType(library.getIntType(), library.getCharType()));
|
||||
assertType("#(1, 'a')", KotlinBuiltIns.getInstance().getTupleType(builtIns.getIntType(), builtIns.getCharType()));
|
||||
}
|
||||
|
||||
public void testTypeInfo() throws Exception {
|
||||
@@ -598,7 +597,7 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
||||
private WritableScopeImpl addImports(JetScope scope) {
|
||||
WritableScopeImpl writableScope = new WritableScopeImpl(
|
||||
scope, scope.getContainingDeclaration(), RedeclarationHandler.DO_NOTHING, "JetTypeCheckerTest.addImports");
|
||||
writableScope.importScope(library.getLibraryScope());
|
||||
writableScope.importScope(builtIns.getBuiltInsScope());
|
||||
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(BuiltinsScopeExtensionMode.ALL, getProject());
|
||||
JavaDescriptorResolver javaDescriptorResolver = injector.getJavaDescriptorResolver();
|
||||
writableScope.importScope(javaDescriptorResolver.resolveNamespace(FqName.ROOT,
|
||||
@@ -658,7 +657,7 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
||||
"fun f<T>(a : Float) : T {a}",
|
||||
};
|
||||
|
||||
public JetScope BASIC_SCOPE = new JetScopeAdapter(library.getLibraryScope()) {
|
||||
public JetScope BASIC_SCOPE = new JetScopeAdapter(builtIns.getBuiltInsScope()) {
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
if (CLASSES.isEmpty()) {
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
@@ -64,8 +63,7 @@ public class JetPluginUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
|
||||
JetScope libraryScope = standardLibrary.getLibraryScope();
|
||||
JetScope libraryScope = KotlinBuiltIns.getInstance().getBuiltInsScope();
|
||||
|
||||
DeclarationDescriptor declaration = type.getMemberScope().getContainingDeclaration();
|
||||
if (ErrorUtils.isError(declaration)) {
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.jet.plugin;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
/**
|
||||
* This project component initializes JetStandardLibrary so that throwing a ProcessCanceledException while
|
||||
@@ -32,7 +32,7 @@ public class JetStandardLibraryInitializer {
|
||||
ProgressManager.getInstance().executeNonCancelableSection(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JetStandardLibrary.initialize(project);
|
||||
KotlinBuiltIns.initialize(project);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -45,7 +45,6 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.plugin.stubindex.JetExtensionFunctionNameIndex;
|
||||
import org.jetbrains.jet.plugin.stubindex.JetFullClassNameIndex;
|
||||
import org.jetbrains.jet.plugin.stubindex.JetShortClassNameIndex;
|
||||
@@ -120,16 +119,15 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
||||
*/
|
||||
@NotNull
|
||||
public static Collection<DeclarationDescriptor> getJetOnlyTypes() {
|
||||
Collection<DeclarationDescriptor> standardTypes = KotlinBuiltIns.getInstance().getAllBuiltInClasses();
|
||||
standardTypes.addAll(
|
||||
Collections2.transform(JetStandardLibrary.getInstance().getStandardTypes(),
|
||||
new Function<ClassDescriptor, DeclarationDescriptor>() {
|
||||
Collection<DeclarationDescriptor> standardTypes =
|
||||
Collections2.transform(KotlinBuiltIns.getInstance().getAllBuiltInClasses(),
|
||||
new Function<DeclarationDescriptor, DeclarationDescriptor>() {
|
||||
@Override
|
||||
public DeclarationDescriptor apply(@Nullable ClassDescriptor classDescriptor) {
|
||||
public DeclarationDescriptor apply(@Nullable DeclarationDescriptor classDescriptor) {
|
||||
assert classDescriptor != null;
|
||||
return classDescriptor;
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
return standardTypes;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.plugin.project.WholeProjectAnalyzerFacade;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
@@ -143,7 +142,7 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
|
||||
|
||||
bodyBuilder.append(descriptor.getName()).append(" : ").append(DescriptorRenderer.COMPACT_WITH_MODIFIERS.renderTypeWithShortNames(
|
||||
descriptor.getType()));
|
||||
String initializer = defaultInitializer(descriptor.getType(), JetStandardLibrary.getInstance());
|
||||
String initializer = defaultInitializer(descriptor.getType(), KotlinBuiltIns.getInstance());
|
||||
if (initializer != null) {
|
||||
bodyBuilder.append(" = ").append(initializer);
|
||||
}
|
||||
@@ -227,9 +226,9 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
|
||||
delegationBuilder.append(")");
|
||||
}
|
||||
final JetType returnType = descriptor.getReturnType();
|
||||
final JetStandardLibrary stdlib = JetStandardLibrary.getInstance();
|
||||
final KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
|
||||
|
||||
boolean returnsNotUnit = returnType != null && !stdlib.getTuple0Type().equals(returnType);
|
||||
boolean returnsNotUnit = returnType != null && !builtIns.getUnitType().equals(returnType);
|
||||
if (returnsNotUnit) {
|
||||
bodyBuilder.append(" : ").append(renderType(returnType));
|
||||
}
|
||||
@@ -248,16 +247,16 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
|
||||
}
|
||||
}
|
||||
|
||||
private static String defaultInitializer(JetType returnType, JetStandardLibrary stdlib) {
|
||||
private static String defaultInitializer(JetType returnType, KotlinBuiltIns builtIns) {
|
||||
if (returnType.isNullable()) {
|
||||
return "null";
|
||||
}
|
||||
else if (returnType.equals(stdlib.getIntType()) || returnType.equals(stdlib.getLongType()) ||
|
||||
returnType.equals(stdlib.getShortType()) || returnType.equals(stdlib.getByteType()) ||
|
||||
returnType.equals(stdlib.getFloatType()) || returnType.equals(stdlib.getDoubleType())) {
|
||||
else if (returnType.equals(builtIns.getIntType()) || returnType.equals(builtIns.getLongType()) ||
|
||||
returnType.equals(builtIns.getShortType()) || returnType.equals(builtIns.getByteType()) ||
|
||||
returnType.equals(builtIns.getFloatType()) || returnType.equals(builtIns.getDoubleType())) {
|
||||
return "0";
|
||||
}
|
||||
else if (returnType.equals(stdlib.getBooleanType())) {
|
||||
else if (returnType.equals(builtIns.getBooleanType())) {
|
||||
return "false";
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
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 org.jetbrains.jet.lexer.JetLexer;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.project.AnalyzeSingleFileUtil;
|
||||
@@ -79,65 +79,65 @@ public class JetNameSuggester {
|
||||
}
|
||||
|
||||
private static void addNamesForType(ArrayList<String> result, JetType jetType, JetNameValidator validator) {
|
||||
JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
|
||||
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
|
||||
JetTypeChecker typeChecker = JetTypeChecker.INSTANCE;
|
||||
if (ErrorUtils.containsErrorType(jetType)) return;
|
||||
if (typeChecker.equalTypes(standardLibrary.getBooleanType(), jetType)) {
|
||||
if (typeChecker.equalTypes(builtIns.getBooleanType(), jetType)) {
|
||||
addName(result, "b", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getIntType(), jetType)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getIntType(), jetType)) {
|
||||
addName(result, "i", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getByteType(), jetType)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getByteType(), jetType)) {
|
||||
addName(result, "byte", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getLongType(), jetType)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getLongType(), jetType)) {
|
||||
addName(result, "l", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getFloatType(), jetType)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getFloatType(), jetType)) {
|
||||
addName(result, "fl", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getDoubleType(), jetType)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getDoubleType(), jetType)) {
|
||||
addName(result, "d", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getShortType(), jetType)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getShortType(), jetType)) {
|
||||
addName(result, "sh", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getCharType(), jetType)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getCharType(), jetType)) {
|
||||
addName(result, "c", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getStringType(), jetType)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getStringType(), jetType)) {
|
||||
addName(result, "s", validator);
|
||||
}
|
||||
else {
|
||||
if (jetType.getArguments().size() == 1) {
|
||||
JetType argument = jetType.getArguments().get(0).getType();
|
||||
if (typeChecker.equalTypes(standardLibrary.getArrayType(argument), jetType)) {
|
||||
if (typeChecker.equalTypes(standardLibrary.getBooleanType(), argument)) {
|
||||
if (typeChecker.equalTypes(builtIns.getArrayType(argument), jetType)) {
|
||||
if (typeChecker.equalTypes(builtIns.getBooleanType(), argument)) {
|
||||
addName(result, "booleans", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getIntType(), argument)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getIntType(), argument)) {
|
||||
addName(result, "ints", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getByteType(), argument)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getByteType(), argument)) {
|
||||
addName(result, "bytes", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getLongType(), argument)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getLongType(), argument)) {
|
||||
addName(result, "longs", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getFloatType(), argument)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getFloatType(), argument)) {
|
||||
addName(result, "floats", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getDoubleType(), argument)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getDoubleType(), argument)) {
|
||||
addName(result, "doubles", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getShortType(), argument)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getShortType(), argument)) {
|
||||
addName(result, "shorts", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getCharType(), argument)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getCharType(), argument)) {
|
||||
addName(result, "chars", validator);
|
||||
}
|
||||
else if (typeChecker.equalTypes(standardLibrary.getStringType(), argument)) {
|
||||
else if (typeChecker.equalTypes(builtIns.getStringType(), argument)) {
|
||||
addName(result, "strings", validator);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.NamespaceType;
|
||||
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 javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
@@ -112,8 +112,8 @@ public class JetRefactoringUtil {
|
||||
BindingContext bindingContext = getContextForSingleFile((JetFile)expression.getContainingFile());
|
||||
JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
|
||||
if (expressionType == null || !(expressionType instanceof NamespaceType) &&
|
||||
!JetTypeChecker.INSTANCE.equalTypes(JetStandardLibrary.
|
||||
getInstance().getTuple0Type(), expressionType)) {
|
||||
!JetTypeChecker.INSTANCE.equalTypes(KotlinBuiltIns.
|
||||
getInstance().getUnitType(), expressionType)) {
|
||||
expressions.add(expression);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -45,7 +45,7 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.NamespaceType;
|
||||
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 org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.codeInsight.ReferenceToClassesShortening;
|
||||
import org.jetbrains.jet.plugin.project.AnalyzeSingleFileUtil;
|
||||
@@ -139,7 +139,7 @@ public class JetIntroduceVariableHandler extends JetIntroduceHandlerBase {
|
||||
return;
|
||||
}
|
||||
if (expressionType != null &&
|
||||
JetTypeChecker.INSTANCE.equalTypes(JetStandardLibrary.getInstance().getTuple0Type(), expressionType)) {
|
||||
JetTypeChecker.INSTANCE.equalTypes(KotlinBuiltIns.getInstance().getUnitType(), expressionType)) {
|
||||
showErrorHint(project, editor, JetRefactoringBundle.message("cannot.refactor.expression.has.unit.type"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.ScopeProvider;
|
||||
import org.jetbrains.jet.lang.types.DependencyClassByQualifiedNameResolverDummyImpl;
|
||||
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -162,7 +162,7 @@ public class AllInjectorsGenerator {
|
||||
generator.addPublicField(ExpressionTypingServices.class);
|
||||
generator.addPublicField(TypeResolver.class);
|
||||
generator.addPublicField(CallResolver.class);
|
||||
generator.addField(true, JetStandardLibrary.class, null, new GivenExpression("JetStandardLibrary.getInstance()"));
|
||||
generator.addField(true, KotlinBuiltIns.class, null, new GivenExpression("KotlinBuiltIns.getInstance()"));
|
||||
generator.addField(false, ModuleConfiguration.class, null, new GivenExpression("ModuleConfiguration.EMPTY"));
|
||||
|
||||
// Parameters
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
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.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -82,7 +81,7 @@ public class JsConfiguration implements ModuleConfiguration {
|
||||
|
||||
// Extend root namespace with standard classes
|
||||
if (namespaceDescriptor.getQualifiedName().shortNameOrSpecial().equals(FqNameUnsafe.ROOT_NAME)) {
|
||||
namespaceMemberScope.importScope(JetStandardLibrary.getInstance().getLibraryScope());
|
||||
namespaceMemberScope.importScope(KotlinBuiltIns.getInstance().getBuiltInsScope());
|
||||
}
|
||||
|
||||
if (hasPreanalyzedContextForTests()) {
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.k2js.analyze.AnalyzerFacadeForJS;
|
||||
import org.jetbrains.k2js.config.Config;
|
||||
import org.jetbrains.k2js.facade.exceptions.TranslationException;
|
||||
@@ -90,7 +90,7 @@ public final class K2JSTranslator {
|
||||
public JsProgram generateProgram(@NotNull List<JetFile> filesToTranslate,
|
||||
@NotNull MainCallParameters mainCallParameters)
|
||||
throws TranslationException {
|
||||
JetStandardLibrary.initialize(config.getProject());
|
||||
KotlinBuiltIns.initialize(config.getProject());
|
||||
BindingContext bindingContext = AnalyzerFacadeForJS.analyzeFilesAndCheckErrors(filesToTranslate, config);
|
||||
return Translation.generateAst(bindingContext, filesToTranslate, mainCallParameters, config);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
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.k2js.translate.context.TranslationContext;
|
||||
|
||||
import java.util.List;
|
||||
@@ -158,7 +157,7 @@ public final class JsDescriptorUtils {
|
||||
if (namespace == null) {
|
||||
return false;
|
||||
}
|
||||
return namespace.equals(JetStandardLibrary.getInstance().getLibraryScope().getContainingDeclaration());
|
||||
return namespace.equals(KotlinBuiltIns.getInstance().getBuiltInsScope().getContainingDeclaration());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user