JetStandardClasses -> KotlinBuiltIns
This commit is contained in:
@@ -37,7 +37,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -81,7 +81,7 @@ public class CodegenUtil {
|
||||
public static SimpleFunctionDescriptor createInvoke(FunctionDescriptor fd) {
|
||||
int arity = fd.getValueParameters().size();
|
||||
SimpleFunctionDescriptorImpl invokeDescriptor = new SimpleFunctionDescriptorImpl(
|
||||
fd.getExpectedThisObject().exists() ? JetStandardClasses.getReceiverFunction(arity) : JetStandardClasses.getFunction(arity),
|
||||
fd.getExpectedThisObject().exists() ? KotlinBuiltIns.getInstance().getExtensionFunction(arity) : KotlinBuiltIns.getInstance().getFunction(arity),
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Name.identifier("invoke"),
|
||||
CallableMemberDescriptor.Kind.DECLARATION);
|
||||
@@ -196,7 +196,7 @@ public class CodegenUtil {
|
||||
return descriptor.getDefaultType();
|
||||
}
|
||||
}
|
||||
return JetStandardClasses.getAnyType();
|
||||
return KotlinBuiltIns.getInstance().getAnyType();
|
||||
}
|
||||
|
||||
public static <T extends CallableMemberDescriptor> T unwrapFakeOverride(T member) {
|
||||
|
||||
@@ -54,7 +54,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
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.JetStandardClasses;
|
||||
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;
|
||||
@@ -2474,7 +2474,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
else {
|
||||
JetType type = ((FunctionDescriptor) op).getReturnType();
|
||||
assert type != null;
|
||||
final boolean keepReturnValue = !type.equals(JetStandardClasses.getUnitType());
|
||||
final boolean keepReturnValue = !type.equals(KotlinBuiltIns.getInstance().getUnitType());
|
||||
callAugAssignMethod(expression, (CallableMethod) callable, lhsType, keepReturnValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ 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.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
@@ -441,7 +441,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
private void generateDataClassEqualsIfNeeded(List<PropertyDescriptor> properties) {
|
||||
ClassDescriptor booleanClass = JetStandardLibrary.getInstance().getBoolean();
|
||||
ClassDescriptor anyClass = JetStandardClasses.getAny();
|
||||
ClassDescriptor anyClass = KotlinBuiltIns.getInstance().getAny();
|
||||
FunctionDescriptor equalsFunction = getDeclaredFunctionByRawSignature(descriptor, Name.identifier("equals"), booleanClass, anyClass);
|
||||
if (equalsFunction == null) {
|
||||
generateDataClassEqualsMethod(properties);
|
||||
|
||||
+3
-3
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -65,8 +65,8 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
||||
false,
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
Collections.singleton((funDescriptor.getReceiverParameter().exists()
|
||||
? JetStandardClasses.getReceiverFunction(arity)
|
||||
: JetStandardClasses.getFunction(arity)).getDefaultType()), JetScope.EMPTY,
|
||||
? KotlinBuiltIns.getInstance().getExtensionFunction(arity)
|
||||
: KotlinBuiltIns.getInstance().getFunction(arity)).getDefaultType()), JetScope.EMPTY,
|
||||
Collections.<ConstructorDescriptor>emptySet(), null);
|
||||
|
||||
assert PsiCodegenPredictor.checkPredictedClassNameForFun(bindingContext, funDescriptor, classDescriptor);
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
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.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.util.slicedmap.Slices;
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
|
||||
@@ -125,7 +125,7 @@ public class CodegenBinding {
|
||||
classDescriptor.initialize(
|
||||
false,
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
Collections.singletonList(JetStandardClasses.getAnyType()),
|
||||
Collections.singletonList(KotlinBuiltIns.getInstance().getAnyType()),
|
||||
JetScope.EMPTY,
|
||||
Collections.<ConstructorDescriptor>emptySet(),
|
||||
null);
|
||||
|
||||
@@ -23,10 +23,11 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
||||
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.types.expressions.OperatorConventions;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.PrimitiveType;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@@ -119,16 +120,17 @@ public class IntrinsicMethods {
|
||||
declareIntrinsicFunction(Name.identifier("CharSequence"), Name.identifier("get"), 1, new StringGetChar());
|
||||
declareIntrinsicFunction(Name.identifier("String"), Name.identifier("get"), 1, new StringGetChar());
|
||||
|
||||
intrinsicsMap.registerIntrinsic(JetStandardClasses.STANDARD_CLASSES_FQNAME, Name.identifier("name"), 0, new EnumName());
|
||||
intrinsicsMap.registerIntrinsic(JetStandardClasses.STANDARD_CLASSES_FQNAME, Name.identifier("ordinal"), 0, new EnumOrdinal());
|
||||
FqName builtInsPackageFqName = KotlinBuiltIns.getInstance().getBuiltInsPackageFqName();
|
||||
intrinsicsMap.registerIntrinsic(builtInsPackageFqName, Name.identifier("name"), 0, new EnumName());
|
||||
intrinsicsMap.registerIntrinsic(builtInsPackageFqName, Name.identifier("ordinal"), 0, new EnumOrdinal());
|
||||
|
||||
intrinsicsMap.registerIntrinsic(JetStandardClasses.STANDARD_CLASSES_FQNAME, Name.identifier("toString"), 0, TO_STRING);
|
||||
intrinsicsMap.registerIntrinsic(JetStandardClasses.STANDARD_CLASSES_FQNAME, Name.identifier("equals"), 1, EQUALS);
|
||||
intrinsicsMap.registerIntrinsic(JetStandardClasses.STANDARD_CLASSES_FQNAME, Name.identifier("identityEquals"), 1, IDENTITY_EQUALS);
|
||||
intrinsicsMap.registerIntrinsic(JetStandardClasses.STANDARD_CLASSES_FQNAME, Name.identifier("plus"), 1, STRING_PLUS);
|
||||
intrinsicsMap.registerIntrinsic(JetStandardClasses.STANDARD_CLASSES_FQNAME, Name.identifier("arrayOfNulls"), 1, new NewArray());
|
||||
intrinsicsMap.registerIntrinsic(JetStandardClasses.STANDARD_CLASSES_FQNAME, Name.identifier("synchronized"), 2, new StupidSync());
|
||||
intrinsicsMap.registerIntrinsic(JetStandardClasses.STANDARD_CLASSES_FQNAME, Name.identifier("iterator"), 0, new IteratorIterator());
|
||||
intrinsicsMap.registerIntrinsic(builtInsPackageFqName, Name.identifier("toString"), 0, TO_STRING);
|
||||
intrinsicsMap.registerIntrinsic(builtInsPackageFqName, Name.identifier("equals"), 1, EQUALS);
|
||||
intrinsicsMap.registerIntrinsic(builtInsPackageFqName, Name.identifier("identityEquals"), 1, IDENTITY_EQUALS);
|
||||
intrinsicsMap.registerIntrinsic(builtInsPackageFqName, Name.identifier("plus"), 1, STRING_PLUS);
|
||||
intrinsicsMap.registerIntrinsic(builtInsPackageFqName, Name.identifier("arrayOfNulls"), 1, new NewArray());
|
||||
intrinsicsMap.registerIntrinsic(builtInsPackageFqName, Name.identifier("synchronized"), 2, new StupidSync());
|
||||
intrinsicsMap.registerIntrinsic(builtInsPackageFqName, Name.identifier("iterator"), 0, new IteratorIterator());
|
||||
|
||||
|
||||
declareIntrinsicFunction(Name.identifier("ByteIterator"), Name.identifier("next"), 0, ITERATOR_NEXT);
|
||||
@@ -148,7 +150,7 @@ public class IntrinsicMethods {
|
||||
declareIntrinsicProperty(Name.identifier("CharSequence"), Name.identifier("length"), new StringLength());
|
||||
declareIntrinsicProperty(Name.identifier("String"), Name.identifier("length"), new StringLength());
|
||||
|
||||
Name tuple0Name = JetStandardClasses.getTuple(0).getName();
|
||||
Name tuple0Name = KotlinBuiltIns.getInstance().getTuple(0).getName();
|
||||
intrinsicsMap.registerIntrinsic(
|
||||
getClassObjectFqName(tuple0Name),
|
||||
Name.identifier("VALUE"), -1, new UnitValue());
|
||||
@@ -164,7 +166,7 @@ public class IntrinsicMethods {
|
||||
|
||||
@NotNull
|
||||
private static FqNameUnsafe getClassObjectFqName(@NotNull Name builtinClassName) {
|
||||
return JetStandardClasses.STANDARD_CLASSES_FQNAME.child(builtinClassName).toUnsafe().child(getClassObjectName(builtinClassName));
|
||||
return KotlinBuiltIns.getInstance().getBuiltInsPackageFqName().child(builtinClassName).toUnsafe().child(getClassObjectName(builtinClassName));
|
||||
}
|
||||
|
||||
private void declareArrayMethods() {
|
||||
@@ -201,11 +203,11 @@ public class IntrinsicMethods {
|
||||
}
|
||||
|
||||
private void declareIntrinsicProperty(Name className, Name methodName, IntrinsicMethod implementation) {
|
||||
intrinsicsMap.registerIntrinsic(JetStandardClasses.STANDARD_CLASSES_FQNAME.child(className), methodName, -1, implementation);
|
||||
intrinsicsMap.registerIntrinsic(KotlinBuiltIns.getInstance().getBuiltInsPackageFqName().child(className), methodName, -1, implementation);
|
||||
}
|
||||
|
||||
private void declareIntrinsicFunction(Name className, Name functionName, int arity, IntrinsicMethod implementation) {
|
||||
intrinsicsMap.registerIntrinsic(JetStandardClasses.STANDARD_CLASSES_FQNAME.child(className), functionName, arity, implementation);
|
||||
intrinsicsMap.registerIntrinsic(KotlinBuiltIns.getInstance().getBuiltInsPackageFqName().child(className), functionName, arity, implementation);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.jet.lang.resolve.java.*;
|
||||
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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -173,19 +173,19 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
@NotNull
|
||||
private Type mapReturnType(@NotNull final JetType jetType, @Nullable BothSignatureWriter signatureVisitor) {
|
||||
if (jetType.equals(JetStandardClasses.getUnitType())) {
|
||||
if (jetType.equals(KotlinBuiltIns.getInstance().getUnitType())) {
|
||||
if (signatureVisitor != null) {
|
||||
signatureVisitor.writeAsmType(Type.VOID_TYPE, false);
|
||||
}
|
||||
return Type.VOID_TYPE;
|
||||
}
|
||||
else if (jetType.equals(JetStandardClasses.getNothingType())) {
|
||||
else if (jetType.equals(KotlinBuiltIns.getInstance().getNothingType())) {
|
||||
if (signatureVisitor != null) {
|
||||
signatureVisitor.writeNothing(false);
|
||||
}
|
||||
return Type.VOID_TYPE;
|
||||
}
|
||||
if (jetType.equals(JetStandardClasses.getNullableNothingType())) {
|
||||
if (jetType.equals(KotlinBuiltIns.getInstance().getNullableNothingType())) {
|
||||
if (signatureVisitor != null) {
|
||||
signatureVisitor.writeNothing(true);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollectorToString;
|
||||
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.codegen.ClassBuilderFactories;
|
||||
import org.jetbrains.jet.codegen.CompilationErrorHandler;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.di.InjectorForTopDownAnalyzerForJvm;
|
||||
@@ -52,10 +53,9 @@ 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.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.Progress;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
@@ -261,7 +261,7 @@ public class ReplInterpreter {
|
||||
|
||||
earlierLines.add(new EarlierLine(line, scriptDescriptor, scriptClass, scriptInstance, scriptClassName));
|
||||
|
||||
return LineResult.successful(rv, scriptDescriptor.getReturnType().equals(JetStandardClasses.getUnitType()));
|
||||
return LineResult.successful(rv, scriptDescriptor.getReturnType().equals(KotlinBuiltIns.getInstance().getUnitType()));
|
||||
} catch (Throwable e) {
|
||||
PrintWriter writer = new PrintWriter(System.err);
|
||||
classLoader.dumpClasses(writer);
|
||||
@@ -282,7 +282,7 @@ public class ReplInterpreter {
|
||||
|
||||
// map "jet" namespace into JetStandardLibrary/Classes
|
||||
// @see DefaultModuleConfiguraiton#extendNamespaceScope
|
||||
injector.getNamespaceFactory().createNamespaceDescriptorPathIfNeeded(JetStandardClasses.STANDARD_CLASSES_FQNAME);
|
||||
injector.getNamespaceFactory().createNamespaceDescriptorPathIfNeeded(KotlinBuiltIns.getInstance().getBuiltInsPackageFqName());
|
||||
|
||||
// Import a scope that contains all top-level namespaces that come from dependencies
|
||||
// This makes the namespaces visible at all, does not import themselves
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.PrimitiveType;
|
||||
|
||||
@@ -70,7 +70,7 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
|
||||
primitiveTypesMap.put(jvmPrimitiveType.getWrapper().getFqName().getFqName(), JetStandardLibrary.getInstance().getNullablePrimitiveJetType(
|
||||
primitiveType));
|
||||
}
|
||||
primitiveTypesMap.put("void", JetStandardClasses.getUnitType());
|
||||
primitiveTypesMap.put("void", KotlinBuiltIns.getInstance().getUnitType());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ 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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
@@ -32,7 +32,7 @@ public abstract class JavaToKotlinClassMapBuilder {
|
||||
/*package*/ void init() {
|
||||
JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
|
||||
|
||||
register(Object.class, JetStandardClasses.getAny());
|
||||
register(Object.class, KotlinBuiltIns.getInstance().getAny());
|
||||
register(String.class, standardLibrary.getString());
|
||||
register(CharSequence.class, standardLibrary.getCharSequence());
|
||||
register(Throwable.class, standardLibrary.getThrowable());
|
||||
|
||||
+4
-4
@@ -23,7 +23,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
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.JetStandardClasses;
|
||||
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;
|
||||
@@ -61,7 +61,7 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
|
||||
}
|
||||
}
|
||||
if (descriptor == 'V') {
|
||||
return JetStandardClasses.getUnitType();
|
||||
return KotlinBuiltIns.getInstance().getUnitType();
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -119,12 +119,12 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
|
||||
// TODO: this is the worst code in Kotlin project
|
||||
Matcher functionMatcher = Pattern.compile("jet\\.Function(\\d+)").matcher(ourName.getFqName());
|
||||
if (functionMatcher.matches()) {
|
||||
return JetStandardClasses.getFunction(Integer.parseInt(functionMatcher.group(1)));
|
||||
return KotlinBuiltIns.getInstance().getFunction(Integer.parseInt(functionMatcher.group(1)));
|
||||
}
|
||||
|
||||
Matcher patternMatcher = Pattern.compile("jet\\.Tuple(\\d+)").matcher(ourName.getFqName());
|
||||
if (patternMatcher.matches()) {
|
||||
return JetStandardClasses.getTuple(Integer.parseInt(patternMatcher.group(1)));
|
||||
return KotlinBuiltIns.getInstance().getTuple(Integer.parseInt(patternMatcher.group(1)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.psi.JetTypeElement;
|
||||
import org.jetbrains.jet.lang.psi.JetTypeReference;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
import java.util.List;
|
||||
@@ -89,7 +89,7 @@ public abstract class ElementAlternativeSignatureData {
|
||||
@Nullable JetTypeReference altReturnTypeReference,
|
||||
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters) {
|
||||
if (altReturnTypeReference == null) {
|
||||
if (JetStandardClasses.isUnit(originalType)) {
|
||||
if (KotlinBuiltIns.getInstance().isUnit(originalType)) {
|
||||
return originalType;
|
||||
}
|
||||
else {
|
||||
|
||||
+6
-6
@@ -30,7 +30,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.java.KotlinToJavaTypesMap;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
import java.util.*;
|
||||
@@ -70,13 +70,13 @@ class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
@Override
|
||||
public JetType visitFunctionType(JetFunctionType type, Void data) {
|
||||
return visitCommonType(type.getReceiverTypeRef() == null
|
||||
? JetStandardClasses.getFunction(type.getParameters().size())
|
||||
: JetStandardClasses.getReceiverFunction(type.getParameters().size()), type);
|
||||
? KotlinBuiltIns.getInstance().getFunction(type.getParameters().size())
|
||||
: KotlinBuiltIns.getInstance().getExtensionFunction(type.getParameters().size()), type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetType visitTupleType(JetTupleType type, Void data) {
|
||||
return visitCommonType(JetStandardClasses.getTuple(type.getComponentTypeRefs().size()), type);
|
||||
return visitCommonType(KotlinBuiltIns.getInstance().getTuple(type.getComponentTypeRefs().size()), type);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,8 +87,8 @@ class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
String shortName = type.getReferenceExpression().getReferencedName();
|
||||
String longName = (qualifier == null ? "" : qualifier.getText() + ".") + shortName;
|
||||
|
||||
if (JetStandardClasses.UNIT_ALIAS.getName().equals(longName)) {
|
||||
return visitCommonType(JetStandardClasses.getTuple(0), type);
|
||||
if (KotlinBuiltIns.getInstance().UNIT_ALIAS.getName().equals(longName)) {
|
||||
return visitCommonType(KotlinBuiltIns.getInstance().getTuple(0), type);
|
||||
}
|
||||
|
||||
return visitCommonType(longName, type);
|
||||
|
||||
+3
-3
@@ -31,7 +31,7 @@ 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.Variance;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
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;
|
||||
@@ -278,7 +278,7 @@ public final class JavaSignatureResolver {
|
||||
final List<JetType> upperBoundsForKotlin = typeParameter.upperBoundsForKotlin;
|
||||
assert upperBoundsForKotlin != null;
|
||||
if (upperBoundsForKotlin.size() == 0){
|
||||
typeParameterDescriptor.addUpperBound(JetStandardClasses.getNullableAnyType());
|
||||
typeParameterDescriptor.addUpperBound(KotlinBuiltIns.getInstance().getNullableAnyType());
|
||||
}
|
||||
else {
|
||||
for (JetType upperBound : upperBoundsForKotlin) {
|
||||
@@ -291,7 +291,7 @@ public final class JavaSignatureResolver {
|
||||
else {
|
||||
PsiClassType[] referencedTypes = typeParameter.psiTypeParameter.getExtendsList().getReferencedTypes();
|
||||
if (referencedTypes.length == 0){
|
||||
typeParameterDescriptor.addUpperBound(JetStandardClasses.getNullableAnyType());
|
||||
typeParameterDescriptor.addUpperBound(KotlinBuiltIns.getInstance().getNullableAnyType());
|
||||
}
|
||||
else if (referencedTypes.length == 1) {
|
||||
typeParameterDescriptor.addUpperBound(semanticServices.getTypeTransformer().transformToType(referencedTypes[0], JavaTypeTransformer.TypeUsage.UPPER_BOUND, typeVariableByPsiResolver));
|
||||
|
||||
+4
-4
@@ -32,7 +32,7 @@ import org.jetbrains.jet.lang.resolve.java.wrapper.PsiClassWrapper;
|
||||
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.JetStandardClasses;
|
||||
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;
|
||||
@@ -123,7 +123,7 @@ public final class JavaSupertypesResolver {
|
||||
typeVariableResolver) {
|
||||
@Override
|
||||
protected void done(@NotNull JetType jetType) {
|
||||
if (!jetType.equals(JetStandardClasses.getAnyType())) {
|
||||
if (!jetType.equals(KotlinBuiltIns.getInstance().getAnyType())) {
|
||||
result.add(jetType);
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ public final class JavaSupertypesResolver {
|
||||
|| DescriptorResolverUtils.OBJECT_FQ_NAME.equalsTo(psiClass.getQualifiedName())
|
||||
// TODO: annotations
|
||||
|| classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS) {
|
||||
result.add(JetStandardClasses.getAnyType());
|
||||
result.add(KotlinBuiltIns.getInstance().getAnyType());
|
||||
}
|
||||
else {
|
||||
ClassDescriptor object = resolveJavaLangObject();
|
||||
@@ -156,7 +156,7 @@ public final class JavaSupertypesResolver {
|
||||
}
|
||||
else {
|
||||
//TODO: hack here
|
||||
result.add(JetStandardClasses.getAnyType());
|
||||
result.add(KotlinBuiltIns.getInstance().getAnyType());
|
||||
// throw new IllegalStateException("Could not resolve java.lang.Object");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -58,13 +58,13 @@ public class DefaultModuleConfiguration implements ModuleConfiguration {
|
||||
|
||||
@Override
|
||||
public void extendNamespaceScope(@NotNull BindingTrace trace, @NotNull NamespaceDescriptor namespaceDescriptor, @NotNull WritableScope namespaceMemberScope) {
|
||||
if (DescriptorUtils.getFQName(namespaceDescriptor).equalsTo(JetStandardClasses.STANDARD_CLASSES_FQNAME)) {
|
||||
if (DescriptorUtils.getFQName(namespaceDescriptor).equalsTo(KotlinBuiltIns.getInstance().getBuiltInsPackageFqName())) {
|
||||
switch (builtinsScopeExtensionMode) {
|
||||
case ALL:
|
||||
namespaceMemberScope.importScope(JetStandardLibrary.getInstance().getLibraryScope());
|
||||
break;
|
||||
case ONLY_STANDARD_CLASSES:
|
||||
namespaceMemberScope.importScope(JetStandardClasses.STANDARD_CLASSES);
|
||||
namespaceMemberScope.importScope(KotlinBuiltIns.getInstance().getBuiltInsScope());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.jetbrains.jet.lang.resolve.constants.BooleanValue;
|
||||
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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
@@ -170,7 +170,7 @@ public class JetControlFlowProcessor {
|
||||
builder.read(expression);
|
||||
if (trace.get(BindingContext.PROCESSED, expression)) {
|
||||
JetType type = trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, expression);
|
||||
if (type != null && JetStandardClasses.isNothing(type)) {
|
||||
if (type != null && KotlinBuiltIns.getInstance().isNothing(type)) {
|
||||
builder.jumpToError(expression);
|
||||
}
|
||||
}
|
||||
@@ -627,7 +627,7 @@ public class JetControlFlowProcessor {
|
||||
builder.read(expression);
|
||||
if (trace.get(BindingContext.PROCESSED, expression)) {
|
||||
JetType type = trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, expression);
|
||||
if (type != null && JetStandardClasses.isNothing(type)) {
|
||||
if (type != null && KotlinBuiltIns.getInstance().isNothing(type)) {
|
||||
builder.jumpToError(expression);
|
||||
}
|
||||
}
|
||||
@@ -669,7 +669,7 @@ public class JetControlFlowProcessor {
|
||||
builder.read(expression);
|
||||
if (trace.get(BindingContext.PROCESSED, expression)) {
|
||||
JetType type = trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, expression);
|
||||
if (type != null && JetStandardClasses.isNothing(type)) {
|
||||
if (type != null && KotlinBuiltIns.getInstance().isNothing(type)) {
|
||||
builder.jumpToError(expression);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetMainDetector;
|
||||
|
||||
@@ -135,7 +135,7 @@ public class JetFlowInformationProvider {
|
||||
|
||||
returnedExpressions.remove(function); // This will be the only "expression" if the body is empty
|
||||
|
||||
if (expectedReturnType != NO_EXPECTED_TYPE && !JetStandardClasses.isUnit(expectedReturnType) && returnedExpressions.isEmpty() && !nothingReturned) {
|
||||
if (expectedReturnType != NO_EXPECTED_TYPE && !KotlinBuiltIns.getInstance().isUnit(expectedReturnType) && returnedExpressions.isEmpty() && !nothingReturned) {
|
||||
trace.report(RETURN_TYPE_MISMATCH.on(bodyExpression, expectedReturnType));
|
||||
}
|
||||
final boolean blockBody = function.hasBlockBody();
|
||||
@@ -157,7 +157,7 @@ public class JetFlowInformationProvider {
|
||||
|
||||
@Override
|
||||
public void visitExpression(JetExpression expression) {
|
||||
if (blockBody && expectedReturnType != NO_EXPECTED_TYPE && !JetStandardClasses.isUnit(expectedReturnType) && !rootUnreachableElements.contains(expression)) {
|
||||
if (blockBody && expectedReturnType != NO_EXPECTED_TYPE && !KotlinBuiltIns.getInstance().isUnit(expectedReturnType) && !rootUnreachableElements.contains(expression)) {
|
||||
noReturnError[0] = true;
|
||||
}
|
||||
}
|
||||
@@ -290,7 +290,7 @@ public class JetFlowInformationProvider {
|
||||
if (operationReference != null) {
|
||||
DeclarationDescriptor descriptor = trace.get(BindingContext.REFERENCE_TARGET, operationReference);
|
||||
if (descriptor instanceof FunctionDescriptor) {
|
||||
if (JetStandardClasses.isUnit(((FunctionDescriptor) descriptor).getReturnType())) {
|
||||
if (KotlinBuiltIns.getInstance().isUnit(((FunctionDescriptor) descriptor).getReturnType())) {
|
||||
hasReassignMethodReturningUnit = true;
|
||||
}
|
||||
}
|
||||
@@ -298,7 +298,7 @@ public class JetFlowInformationProvider {
|
||||
Collection<? extends DeclarationDescriptor> descriptors = trace.get(BindingContext.AMBIGUOUS_REFERENCE_TARGET, operationReference);
|
||||
if (descriptors != null) {
|
||||
for (DeclarationDescriptor referenceDescriptor : descriptors) {
|
||||
if (JetStandardClasses.isUnit(((FunctionDescriptor) referenceDescriptor).getReturnType())) {
|
||||
if (KotlinBuiltIns.getInstance().isUnit(((FunctionDescriptor) referenceDescriptor).getReturnType())) {
|
||||
hasReassignMethodReturningUnit = true;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -123,12 +123,12 @@ public class FunctionDescriptorUtil {
|
||||
public static void initializeFromFunctionType(@NotNull FunctionDescriptorImpl functionDescriptor, @NotNull JetType functionType, @NotNull ReceiverDescriptor expectedThisObject,
|
||||
@NotNull Modality modality, @NotNull Visibility visibility) {
|
||||
|
||||
assert JetStandardClasses.isFunctionType(functionType);
|
||||
functionDescriptor.initialize(JetStandardClasses.getReceiverType(functionType),
|
||||
assert KotlinBuiltIns.getInstance().isFunctionType(functionType);
|
||||
functionDescriptor.initialize(KotlinBuiltIns.getInstance().getReceiverType(functionType),
|
||||
expectedThisObject,
|
||||
Collections.<TypeParameterDescriptorImpl>emptyList(),
|
||||
JetStandardClasses.getValueParameters(functionDescriptor, functionType),
|
||||
JetStandardClasses.getReturnTypeFromFunctionType(functionType),
|
||||
KotlinBuiltIns.getInstance().getValueParameters(functionDescriptor, functionType),
|
||||
KotlinBuiltIns.getInstance().getReturnTypeFromFunctionType(functionType),
|
||||
modality,
|
||||
visibility);
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public class FunctionDescriptorUtil {
|
||||
}
|
||||
|
||||
public static FunctionDescriptor getInvokeFunction(@NotNull JetType functionType) {
|
||||
assert JetStandardClasses.isFunctionType(functionType);
|
||||
assert KotlinBuiltIns.getInstance().isFunctionType(functionType);
|
||||
|
||||
ClassifierDescriptor classDescriptorForFunction = functionType.getConstructor().getDeclarationDescriptor();
|
||||
assert classDescriptorForFunction instanceof ClassDescriptor;
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -88,7 +88,7 @@ public class PropertySetterDescriptor extends PropertyAccessorDescriptor {
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getReturnType() {
|
||||
return JetStandardClasses.getUnitType();
|
||||
return KotlinBuiltIns.getInstance().getUnitType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ScriptReceiver;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -76,7 +76,7 @@ public class ScriptDescriptor extends DeclarationDescriptorNonRootImpl {
|
||||
classDescriptor.initialize(
|
||||
false,
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
Collections.singletonList(JetStandardClasses.getAnyType()),
|
||||
Collections.singletonList(KotlinBuiltIns.getInstance().getAnyType()),
|
||||
classScope,
|
||||
new HashSet<ConstructorDescriptor>(),
|
||||
null);
|
||||
|
||||
+7
-7
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.LazyScopeAdapter;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
import org.jetbrains.jet.util.lazy.LazyValue;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class TypeParameterDescriptorImpl extends DeclarationDescriptorNonRootImp
|
||||
@NotNull Name name,
|
||||
int index) {
|
||||
TypeParameterDescriptorImpl typeParameterDescriptor = createForFurtherModification(containingDeclaration, annotations, reified, variance, name, index);
|
||||
typeParameterDescriptor.addUpperBound(JetStandardClasses.getDefaultBound());
|
||||
typeParameterDescriptor.addUpperBound(KotlinBuiltIns.getInstance().getDefaultBound());
|
||||
typeParameterDescriptor.setInitialized();
|
||||
return typeParameterDescriptor;
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public class TypeParameterDescriptorImpl extends DeclarationDescriptorNonRootImp
|
||||
checkUninitialized();
|
||||
|
||||
if (upperBounds.isEmpty()) {
|
||||
doAddUpperBound(JetStandardClasses.getDefaultBound());
|
||||
doAddUpperBound(KotlinBuiltIns.getInstance().getDefaultBound());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ public class TypeParameterDescriptorImpl extends DeclarationDescriptorNonRootImp
|
||||
assert upperBounds.size() > 0 : "Upper bound list is empty in " + getName();
|
||||
upperBoundsAsType = TypeUtils.intersect(JetTypeChecker.INSTANCE, upperBounds);
|
||||
if (upperBoundsAsType == null) {
|
||||
upperBoundsAsType = JetStandardClasses.getNothingType();
|
||||
upperBoundsAsType = KotlinBuiltIns.getInstance().getNothingType();
|
||||
}
|
||||
}
|
||||
return upperBoundsAsType;
|
||||
@@ -172,14 +172,14 @@ public class TypeParameterDescriptorImpl extends DeclarationDescriptorNonRootImp
|
||||
@NotNull
|
||||
public Set<JetType> getLowerBounds() {
|
||||
//checkInitialized();
|
||||
return Collections.singleton(JetStandardClasses.getNothingType());
|
||||
return Collections.singleton(KotlinBuiltIns.getInstance().getNothingType());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JetType getLowerBoundsAsType() {
|
||||
checkInitialized();
|
||||
return JetStandardClasses.getNothingType();
|
||||
return KotlinBuiltIns.getInstance().getNothingType();
|
||||
}
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ public class TypeParameterDescriptorImpl extends DeclarationDescriptorNonRootImp
|
||||
if (classObjectBoundsAsType == null) {
|
||||
classObjectBoundsAsType = TypeUtils.intersect(JetTypeChecker.INSTANCE, classObjectUpperBounds);
|
||||
if (classObjectBoundsAsType == null) {
|
||||
classObjectBoundsAsType = JetStandardClasses.getNothingType();
|
||||
classObjectBoundsAsType = KotlinBuiltIns.getInstance().getNothingType();
|
||||
}
|
||||
}
|
||||
return classObjectBoundsAsType;
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.expressions.OperatorConventions;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lexer.JetToken;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
@@ -306,7 +306,7 @@ public class JetPsiUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
return JetStandardClasses.UNIT_ALIAS.getName().equals(typeReference.getText());
|
||||
return KotlinBuiltIns.getInstance().UNIT_ALIAS.getName().equals(typeReference.getText());
|
||||
}
|
||||
|
||||
public static boolean isSafeCall(@NotNull Call call) {
|
||||
|
||||
@@ -37,7 +37,7 @@ 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.expressions.ExpressionTypingServices;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
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;
|
||||
@@ -183,7 +183,7 @@ public class DescriptorResolver {
|
||||
else if (jetClass instanceof JetClass && ((JetClass) jetClass).isAnnotation()) {
|
||||
return JetStandardLibrary.getInstance().getAnnotationType();
|
||||
}
|
||||
return JetStandardClasses.getAnyType();
|
||||
return KotlinBuiltIns.getInstance().getAnyType();
|
||||
}
|
||||
|
||||
public Collection<JetType> resolveDelegationSpecifiers(
|
||||
@@ -267,7 +267,7 @@ public class DescriptorResolver {
|
||||
returnType = typeResolver.resolveType(innerScope, returnTypeRef, trace, true);
|
||||
}
|
||||
else if (function.hasBlockBody()) {
|
||||
returnType = JetStandardClasses.getUnitType();
|
||||
returnType = KotlinBuiltIns.getInstance().getUnitType();
|
||||
}
|
||||
else {
|
||||
final JetExpression bodyExpression = function.getBodyExpression();
|
||||
@@ -574,7 +574,7 @@ public class DescriptorResolver {
|
||||
|
||||
parameter.setInitialized();
|
||||
|
||||
if (JetStandardClasses.isNothing(parameter.getUpperBoundsAsType())) {
|
||||
if (KotlinBuiltIns.getInstance().isNothing(parameter.getUpperBoundsAsType())) {
|
||||
PsiElement nameIdentifier = typeParameters.get(parameter.getIndex()).getNameIdentifier();
|
||||
if (nameIdentifier != null) {
|
||||
trace.report(CONFLICTING_UPPER_BOUNDS.on(nameIdentifier, parameter));
|
||||
@@ -582,7 +582,7 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
JetType classObjectType = parameter.getClassObjectType();
|
||||
if (classObjectType != null && JetStandardClasses.isNothing(classObjectType)) {
|
||||
if (classObjectType != null && KotlinBuiltIns.getInstance().isNothing(classObjectType)) {
|
||||
PsiElement nameIdentifier = typeParameters.get(parameter.getIndex()).getNameIdentifier();
|
||||
if (nameIdentifier != null) {
|
||||
trace.report(CONFLICTING_CLASS_OBJECT_UPPER_BOUNDS.on(nameIdentifier, parameter));
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.jet.lang.types.DescriptorSubstitutor;
|
||||
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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.*;
|
||||
@@ -272,7 +272,7 @@ public class DescriptorUtils {
|
||||
}
|
||||
|
||||
public static boolean isNotAny(@NotNull DeclarationDescriptor superClassDescriptor) {
|
||||
return !superClassDescriptor.equals(JetStandardClasses.getAny());
|
||||
return !superClassDescriptor.equals(KotlinBuiltIns.getInstance().getAny());
|
||||
}
|
||||
|
||||
public static boolean inStaticContext(@NotNull DeclarationDescriptor descriptor) {
|
||||
@@ -293,7 +293,7 @@ public class DescriptorUtils {
|
||||
|
||||
public static boolean isIteratorWithoutRemoveImpl(@NotNull ClassDescriptor classDescriptor) {
|
||||
ClassDescriptor iteratorOfT = JetStandardLibrary.getInstance().getIterator();
|
||||
JetType iteratorOfAny = TypeUtils.substituteParameters(iteratorOfT, Collections.singletonList(JetStandardClasses.getAnyType()));
|
||||
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"));
|
||||
return isIterator && !hasRemove;
|
||||
|
||||
@@ -32,7 +32,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.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.*;
|
||||
@@ -163,7 +163,7 @@ public class TopDownAnalyzer {
|
||||
Predicates.<PsiFile>alwaysFalse(), true, false, Collections.<AnalyzerScriptParameter>emptyList());
|
||||
InjectorForTopDownAnalyzerBasic injector = new InjectorForTopDownAnalyzerBasic(
|
||||
project, topDownAnalysisParameters, new ObservableBindingTrace(trace),
|
||||
JetStandardClasses.FAKE_STANDARD_CLASSES_MODULE, ModuleConfiguration.EMPTY);
|
||||
KotlinBuiltIns.getInstance().getBuiltInsModule(), ModuleConfiguration.EMPTY);
|
||||
|
||||
injector.getTopDownAnalyzer().doProcessStandardLibraryNamespace(outerScope, standardLibraryNamespace, files);
|
||||
}
|
||||
@@ -246,7 +246,7 @@ public class TopDownAnalyzer {
|
||||
|
||||
// map "jet" namespace into JetStandardLibrary/Classes
|
||||
// @see DefaultModuleConfiguraiton#extendNamespaceScope
|
||||
namespaceFactory.createNamespaceDescriptorPathIfNeeded(JetStandardClasses.STANDARD_CLASSES_FQNAME);
|
||||
namespaceFactory.createNamespaceDescriptorPathIfNeeded(KotlinBuiltIns.getInstance().getBuiltInsPackageFqName());
|
||||
|
||||
// Import a scope that contains all top-level namespaces that come from dependencies
|
||||
// This makes the namespaces visible at all, does not import themselves
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.LazyScopeAdapter;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.util.lazy.LazyValue;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -188,7 +188,7 @@ public class TypeResolver {
|
||||
}
|
||||
|
||||
// TODO labels
|
||||
result[0] = JetStandardClasses.getTupleType(resolveTypes(scope, type.getComponentTypeRefs(), trace, checkBounds));
|
||||
result[0] = KotlinBuiltIns.getInstance().getTupleType(resolveTypes(scope, type.getComponentTypeRefs(), trace, checkBounds));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,9 +207,9 @@ public class TypeResolver {
|
||||
returnType = resolveType(scope, returnTypeRef, trace, checkBounds);
|
||||
}
|
||||
else {
|
||||
returnType = JetStandardClasses.getUnitType();
|
||||
returnType = KotlinBuiltIns.getInstance().getUnitType();
|
||||
}
|
||||
result[0] = JetStandardClasses.getFunctionType(annotations, receiverType, parameterTypes, returnType);
|
||||
result[0] = KotlinBuiltIns.getInstance().getFunctionType(annotations, receiverType, parameterTypes, returnType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,7 +40,7 @@ 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.expressions.ExpressionTypingUtils;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
|
||||
@@ -235,7 +235,7 @@ public class CallResolver {
|
||||
// Here we handle the case where the callee expression must be something of type function, e.g. (foo.bar())(1, 2)
|
||||
JetType calleeType = expressionTypingServices.safeGetType(context.scope, calleeExpression, NO_EXPECTED_TYPE, context.dataFlowInfo, context.trace); // We are actually expecting a function, but there seems to be no easy way of expressing this
|
||||
|
||||
if (!JetStandardClasses.isFunctionType(calleeType)) {
|
||||
if (!KotlinBuiltIns.getInstance().isFunctionType(calleeType)) {
|
||||
// checkTypesWithNoCallee(trace, scope, call);
|
||||
if (!ErrorUtils.isErrorType(calleeType)) {
|
||||
context.trace.report(CALLEE_NOT_A_FUNCTION.on(calleeExpression, calleeType));
|
||||
|
||||
+3
-3
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.jet.lang.resolve.calls.autocasts;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
/**
|
||||
@@ -25,8 +25,8 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
*/
|
||||
public class DataFlowValue {
|
||||
|
||||
public static final DataFlowValue NULL = new DataFlowValue(new Object(), JetStandardClasses.getNullableNothingType(), false, Nullability.NULL);
|
||||
public static final DataFlowValue NULLABLE = new DataFlowValue(new Object(), JetStandardClasses.getNullableAnyType(), false, Nullability.UNKNOWN);
|
||||
public static final DataFlowValue NULL = new DataFlowValue(new Object(), KotlinBuiltIns.getInstance().getNullableNothingType(), false, Nullability.NULL);
|
||||
public static final DataFlowValue NULLABLE = new DataFlowValue(new Object(), KotlinBuiltIns.getInstance().getNullableAnyType(), false, Nullability.UNKNOWN);
|
||||
|
||||
private final boolean stableIdentifier;
|
||||
private final JetType type;
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.resolve.JetModuleUtil;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ThisReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.REFERENCE_TARGET;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class DataFlowValueFactory {
|
||||
JetConstantExpression constantExpression = (JetConstantExpression) expression;
|
||||
if (constantExpression.getNode().getElementType() == JetNodeTypes.NULL) return DataFlowValue.NULL;
|
||||
}
|
||||
if (TypeUtils.equalTypes(type, JetStandardClasses.getNullableNothingType())) return DataFlowValue.NULL; // 'null' is the only inhabitant of 'Nothing?'
|
||||
if (TypeUtils.equalTypes(type, KotlinBuiltIns.getInstance().getNullableNothingType())) return DataFlowValue.NULL; // 'null' is the only inhabitant of 'Nothing?'
|
||||
Pair<Object, Boolean> result = getIdForStableIdentifier(expression, bindingContext, false);
|
||||
return new DataFlowValue(result.first == null ? expression : result.first, type, result.second, getImmanentNullability(type));
|
||||
}
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.checker.TypeCheckingProcedure;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.TypeConstraintsImpl.ConstraintKind;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -196,7 +196,7 @@ public class ConstraintSystemImpl implements ConstraintSystem {
|
||||
}
|
||||
switch (constraintKind) {
|
||||
case SUPER_TYPE: {
|
||||
if (JetStandardClasses.isNothingOrNullableNothing(constrainingType)) break;
|
||||
if (KotlinBuiltIns.getInstance().isNothingOrNullableNothing(constrainingType)) break;
|
||||
JetType correspondingSupertype = TypeCheckingProcedure.findCorrespondingSupertype(constrainingType, subjectType);
|
||||
if (correspondingSupertype != null) {
|
||||
constrainingType = correspondingSupertype;
|
||||
@@ -204,7 +204,7 @@ public class ConstraintSystemImpl implements ConstraintSystem {
|
||||
break;
|
||||
}
|
||||
case SUB_TYPE: {
|
||||
if (JetStandardClasses.isNothingOrNullableNothing(subjectType)) break;
|
||||
if (KotlinBuiltIns.getInstance().isNothingOrNullableNothing(subjectType)) break;
|
||||
JetType correspondingSupertype = TypeCheckingProcedure.findCorrespondingSupertype(subjectType, constrainingType);
|
||||
if (correspondingSupertype != null) {
|
||||
subjectType = correspondingSupertype;
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ 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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.List;
|
||||
@@ -314,7 +314,7 @@ public class CompileTimeConstantResolver {
|
||||
}
|
||||
|
||||
private boolean noExpectedType(JetType expectedType) {
|
||||
return expectedType == TypeUtils.NO_EXPECTED_TYPE || JetStandardClasses.isUnit(expectedType) || ErrorUtils.isErrorType(expectedType);
|
||||
return expectedType == TypeUtils.NO_EXPECTED_TYPE || KotlinBuiltIns.getInstance().isUnit(expectedType) || ErrorUtils.isErrorType(expectedType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class NullValue implements CompileTimeConstant<Void> {
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
|
||||
return JetStandardClasses.getNullableNothingType();
|
||||
return KotlinBuiltIns.getInstance().getNullableNothingType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-4
@@ -31,7 +31,7 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.LazyScopeAdapter;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.util.lazy.LazyValue;
|
||||
|
||||
@@ -103,7 +103,7 @@ public class LazyTypeParameterDescriptor implements TypeParameterDescriptor, Laz
|
||||
}
|
||||
|
||||
if (upperBounds.isEmpty()) {
|
||||
upperBounds.add(JetStandardClasses.getDefaultBound());
|
||||
upperBounds.add(KotlinBuiltIns.getInstance().getDefaultBound());
|
||||
}
|
||||
}
|
||||
return upperBounds;
|
||||
@@ -155,7 +155,7 @@ public class LazyTypeParameterDescriptor implements TypeParameterDescriptor, Laz
|
||||
assert upperBounds.size() > 0 : "Upper bound list is empty in " + getName();
|
||||
upperBoundsAsType = TypeUtils.intersect(JetTypeChecker.INSTANCE, upperBounds);
|
||||
if (upperBoundsAsType == null) {
|
||||
upperBoundsAsType = JetStandardClasses.getNothingType();
|
||||
upperBoundsAsType = KotlinBuiltIns.getInstance().getNothingType();
|
||||
}
|
||||
}
|
||||
return upperBoundsAsType;
|
||||
@@ -170,7 +170,7 @@ public class LazyTypeParameterDescriptor implements TypeParameterDescriptor, Laz
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getLowerBoundsAsType() {
|
||||
return JetStandardClasses.getNothingType();
|
||||
return KotlinBuiltIns.getInstance().getNothingType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
@@ -45,7 +45,7 @@ public class ScriptReceiver implements ThisReceiverDescriptor {
|
||||
@Override
|
||||
public JetType getType() {
|
||||
// not sure
|
||||
return JetStandardClasses.getAnyType();
|
||||
return KotlinBuiltIns.getInstance().getAnyType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.utils.DFS;
|
||||
|
||||
import java.util.*;
|
||||
@@ -47,7 +47,7 @@ public class CommonSupertypes {
|
||||
for (Iterator<JetType> iterator = typeSet.iterator(); iterator.hasNext();) {
|
||||
JetType type = iterator.next();
|
||||
assert type != null;
|
||||
if (JetStandardClasses.isNothingOrNullableNothing(type)) {
|
||||
if (KotlinBuiltIns.getInstance().isNothingOrNullableNothing(type)) {
|
||||
iterator.remove();
|
||||
}
|
||||
nullable |= type.isNullable();
|
||||
@@ -56,7 +56,7 @@ public class CommonSupertypes {
|
||||
// Everything deleted => it's Nothing or Nothing?
|
||||
if (typeSet.isEmpty()) {
|
||||
// TODO : attributes
|
||||
return nullable ? JetStandardClasses.getNullableNothingType() : JetStandardClasses.getNothingType();
|
||||
return nullable ? KotlinBuiltIns.getInstance().getNullableNothingType() : KotlinBuiltIns.getInstance().getNothingType();
|
||||
}
|
||||
|
||||
if (typeSet.size() == 1) {
|
||||
@@ -199,7 +199,7 @@ public class CommonSupertypes {
|
||||
}
|
||||
|
||||
// TODO : attributes?
|
||||
JetScope newScope = JetStandardClasses.STUB;
|
||||
JetScope newScope = KotlinBuiltIns.getInstance().STUB;
|
||||
DeclarationDescriptor declarationDescriptor = constructor.getDeclarationDescriptor();
|
||||
if (declarationDescriptor instanceof ClassDescriptor) {
|
||||
newScope = ((ClassDescriptor) declarationDescriptor).getMemberScope(newProjections);
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.error.ErrorSimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -227,7 +227,7 @@ public class ErrorUtils {
|
||||
}
|
||||
|
||||
private static JetType createErrorTypeWithCustomDebugName(JetScope memberScope, String debugName) {
|
||||
return new ErrorTypeImpl(new TypeConstructorImpl(ERROR_CLASS, Collections.<AnnotationDescriptor>emptyList(), false, debugName, Collections.<TypeParameterDescriptorImpl>emptyList(), Collections.singleton(JetStandardClasses.getAnyType())), memberScope);
|
||||
return new ErrorTypeImpl(new TypeConstructorImpl(ERROR_CLASS, Collections.<AnnotationDescriptor>emptyList(), false, debugName, Collections.<TypeParameterDescriptorImpl>emptyList(), Collections.singleton(KotlinBuiltIns.getInstance().getAnyType())), memberScope);
|
||||
}
|
||||
|
||||
public static JetType createWrongVarianceErrorType(TypeProjection value) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.google.common.collect.Multimap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.util.CommonSuppliers;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -81,7 +81,7 @@ public class SubstitutionUtils {
|
||||
fullSubstitution.put(typeParameterDescriptor.getTypeConstructor(), substitutedTypeProjection);
|
||||
}
|
||||
}
|
||||
if (JetStandardClasses.isNothingOrNullableNothing(context)) return;
|
||||
if (KotlinBuiltIns.getInstance().isNothingOrNullableNothing(context)) return;
|
||||
for (JetType supertype : context.getConstructor().getSupertypes()) {
|
||||
fillInDeepSubstitutor(supertype, substitutor, substitution, fullSubstitution);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.SubstitutingScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -141,7 +141,7 @@ public class TypeSubstitutor {
|
||||
assertRecursionDepth(recursionDepth, originalProjection, substitution);
|
||||
// The type is within the substitution range, i.e. T or T?
|
||||
JetType type = originalProjection.getType();
|
||||
if (JetStandardClasses.isNothing(type) || ErrorUtils.isErrorType(type)) return originalProjection;
|
||||
if (KotlinBuiltIns.getInstance().isNothing(type) || ErrorUtils.isErrorType(type)) return originalProjection;
|
||||
|
||||
TypeProjection replacement = substitution.get(type.getConstructor());
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintType;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.ChainedScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -104,7 +104,7 @@ public class TypeUtils {
|
||||
@Nullable
|
||||
public static JetType intersect(@NotNull JetTypeChecker typeChecker, @NotNull Set<JetType> types) {
|
||||
if (types.isEmpty()) {
|
||||
return JetStandardClasses.getNullableAnyType();
|
||||
return KotlinBuiltIns.getInstance().getNullableAnyType();
|
||||
}
|
||||
|
||||
if (types.size() == 1) {
|
||||
@@ -117,13 +117,13 @@ public class TypeUtils {
|
||||
boolean nothingTypePresent = false;
|
||||
List<JetType> nullabilityStripped = Lists.newArrayList();
|
||||
for (JetType type : types) {
|
||||
nothingTypePresent |= JetStandardClasses.isNothingOrNullableNothing(type);
|
||||
nothingTypePresent |= KotlinBuiltIns.getInstance().isNothingOrNullableNothing(type);
|
||||
allNullable &= type.isNullable();
|
||||
nullabilityStripped.add(makeNotNullable(type));
|
||||
}
|
||||
|
||||
if (nothingTypePresent) {
|
||||
return allNullable ? JetStandardClasses.getNullableNothingType() : JetStandardClasses.getNothingType();
|
||||
return allNullable ? KotlinBuiltIns.getInstance().getNullableNothingType() : KotlinBuiltIns.getInstance().getNothingType();
|
||||
}
|
||||
|
||||
// Now we remove types that have subtypes in the list
|
||||
|
||||
+3
-3
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class TypeCheckingProcedure {
|
||||
|
||||
private static JetType getInType(TypeParameterDescriptor parameter, TypeProjection argument) {
|
||||
boolean isOutProjected = argument.getProjectionKind() == OUT_VARIANCE || parameter.getVariance() == OUT_VARIANCE;
|
||||
return isOutProjected ? JetStandardClasses.getNothingType() : argument.getType();
|
||||
return isOutProjected ? KotlinBuiltIns.getInstance().getNothingType() : argument.getType();
|
||||
}
|
||||
|
||||
private final TypingConstraints constraints;
|
||||
@@ -164,7 +164,7 @@ public class TypeCheckingProcedure {
|
||||
}
|
||||
subtype = TypeUtils.makeNotNullable(subtype);
|
||||
supertype = TypeUtils.makeNotNullable(supertype);
|
||||
if (JetStandardClasses.isNothingOrNullableNothing(subtype)) {
|
||||
if (KotlinBuiltIns.getInstance().isNothingOrNullableNothing(subtype)) {
|
||||
return true;
|
||||
}
|
||||
@Nullable JetType closestSupertype = findCorrespondingSupertype(subtype, supertype);
|
||||
|
||||
+9
-9
@@ -45,7 +45,7 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
@@ -369,14 +369,14 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
for (JetExpression entry : entries) {
|
||||
types.add(context.expressionTypingServices.safeGetType(context.scope, entry, NO_EXPECTED_TYPE, context.dataFlowInfo, context.trace)); // TODO
|
||||
}
|
||||
if (context.expectedType != NO_EXPECTED_TYPE && JetStandardClasses.isTupleType(context.expectedType)) {
|
||||
if (context.expectedType != NO_EXPECTED_TYPE && KotlinBuiltIns.getInstance().isTupleType(context.expectedType)) {
|
||||
List<JetType> enrichedTypes = checkArgumentTypes(types, entries, context.expectedType.getArguments(), context);
|
||||
if (enrichedTypes != types) {
|
||||
return JetTypeInfo.create(JetStandardClasses.getTupleType(enrichedTypes), context.dataFlowInfo);
|
||||
return JetTypeInfo.create(KotlinBuiltIns.getInstance().getTupleType(enrichedTypes), context.dataFlowInfo);
|
||||
}
|
||||
}
|
||||
// TODO : labels
|
||||
return DataFlowUtils.checkType(JetStandardClasses.getTupleType(types), expression, context, context.dataFlowInfo);
|
||||
return DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getTupleType(types), expression, context, context.dataFlowInfo);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -481,7 +481,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
else {
|
||||
// supertypes may be empty when all the supertypes are error types (are not resolved, for example)
|
||||
JetType type = supertypes.isEmpty()
|
||||
? JetStandardClasses.getAnyType()
|
||||
? KotlinBuiltIns.getInstance().getAnyType()
|
||||
: supertypes.iterator().next();
|
||||
result = substitutor.substitute(type, Variance.INVARIANT);
|
||||
}
|
||||
@@ -565,7 +565,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
|
||||
//TODO move further
|
||||
if (!(receiverType instanceof NamespaceType) && expression.getOperationSign() == JetTokens.SAFE_ACCESS) {
|
||||
if (selectorReturnType != null && !selectorReturnType.isNullable() && !JetStandardClasses.isUnit(selectorReturnType)) {
|
||||
if (selectorReturnType != null && !selectorReturnType.isNullable() && !KotlinBuiltIns.getInstance().isUnit(selectorReturnType)) {
|
||||
if (receiverType.isNullable()) {
|
||||
selectorReturnType = TypeUtils.makeNullable(selectorReturnType);
|
||||
}
|
||||
@@ -847,8 +847,8 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetType returnType = resolutionResults.getResultingDescriptor().getReturnType();
|
||||
JetType result;
|
||||
if (operationType == JetTokens.PLUSPLUS || operationType == JetTokens.MINUSMINUS) {
|
||||
if (JetTypeChecker.INSTANCE.isSubtypeOf(returnType, JetStandardClasses.getUnitType())) {
|
||||
result = ErrorUtils.createErrorType(JetStandardClasses.UNIT_ALIAS.getName());
|
||||
if (JetTypeChecker.INSTANCE.isSubtypeOf(returnType, KotlinBuiltIns.getInstance().getUnitType())) {
|
||||
result = ErrorUtils.createErrorType(KotlinBuiltIns.getInstance().UNIT_ALIAS.getName());
|
||||
context.trace.report(INC_DEC_SHOULD_NOT_RETURN_UNIT.on(operationSign));
|
||||
}
|
||||
else {
|
||||
@@ -994,7 +994,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
ExpressionReceiver receiver = ExpressionTypingUtils.safeGetExpressionReceiver(facade, left, context.replaceScope(context.scope));
|
||||
OverloadResolutionResults<FunctionDescriptor> resolutionResults = context.resolveExactSignature(
|
||||
receiver, name,
|
||||
Collections.singletonList(JetStandardClasses.getNullableAnyType()));
|
||||
Collections.singletonList(KotlinBuiltIns.getInstance().getNullableAnyType()));
|
||||
if (resolutionResults.isSuccess()) {
|
||||
FunctionDescriptor equals = resolutionResults.getResultingCall().getResultingDescriptor();
|
||||
context.trace.record(REFERENCE_TARGET, operationSign, equals);
|
||||
|
||||
+10
-10
@@ -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.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.util.lazy.LazyValueWithDefault;
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
|
||||
@@ -97,7 +97,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
if (bodyExpression == null) return null;
|
||||
|
||||
JetType expectedType = context.expectedType;
|
||||
boolean functionTypeExpected = expectedType != TypeUtils.NO_EXPECTED_TYPE && JetStandardClasses.isFunctionType(expectedType);
|
||||
boolean functionTypeExpected = expectedType != TypeUtils.NO_EXPECTED_TYPE && KotlinBuiltIns.getInstance().isFunctionType(expectedType);
|
||||
|
||||
SimpleFunctionDescriptorImpl functionDescriptor = createFunctionDescriptor(expression, context, functionTypeExpected);
|
||||
|
||||
@@ -120,7 +120,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
else {
|
||||
if (functionTypeExpected) {
|
||||
returnType = JetStandardClasses.getReturnTypeFromFunctionType(expectedType);
|
||||
returnType = KotlinBuiltIns.getInstance().getReturnTypeFromFunctionType(expectedType);
|
||||
}
|
||||
returnType = context.expressionTypingServices.getBlockReturnedType(functionInnerScope, bodyExpression, CoercionStrategy.COERCION_TO_UNIT,
|
||||
context.replaceExpectedType(returnType).replaceBindingTrace(temporaryTrace), temporaryTrace).getType();
|
||||
@@ -136,14 +136,14 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
functionDescriptor.setReturnType(safeReturnType);
|
||||
|
||||
if (!functionLiteral.hasDeclaredReturnType() && functionTypeExpected) {
|
||||
JetType expectedReturnType = JetStandardClasses.getReturnTypeFromFunctionType(expectedType);
|
||||
if (JetStandardClasses.isUnit(expectedReturnType)) {
|
||||
functionDescriptor.setReturnType(JetStandardClasses.getUnitType());
|
||||
return DataFlowUtils.checkType(JetStandardClasses.getFunctionType(Collections.<AnnotationDescriptor>emptyList(), receiver, parameterTypes, JetStandardClasses.getUnitType()), expression, context, context.dataFlowInfo);
|
||||
JetType expectedReturnType = KotlinBuiltIns.getInstance().getReturnTypeFromFunctionType(expectedType);
|
||||
if (KotlinBuiltIns.getInstance().isUnit(expectedReturnType)) {
|
||||
functionDescriptor.setReturnType(KotlinBuiltIns.getInstance().getUnitType());
|
||||
return DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getFunctionType(Collections.<AnnotationDescriptor>emptyList(), receiver, parameterTypes, KotlinBuiltIns.getInstance().getUnitType()), expression, context, context.dataFlowInfo);
|
||||
}
|
||||
|
||||
}
|
||||
return DataFlowUtils.checkType(JetStandardClasses.getFunctionType(Collections.<AnnotationDescriptor>emptyList(), receiver, parameterTypes, safeReturnType), expression, context, context.dataFlowInfo);
|
||||
return DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getFunctionType(Collections.<AnnotationDescriptor>emptyList(), receiver, parameterTypes, safeReturnType), expression, context, context.dataFlowInfo);
|
||||
}
|
||||
|
||||
private SimpleFunctionDescriptorImpl createFunctionDescriptor(JetFunctionLiteralExpression expression, ExpressionTypingContext context, boolean functionTypeExpected) {
|
||||
@@ -157,7 +157,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetType effectiveReceiverType;
|
||||
if (receiverTypeRef == null) {
|
||||
if (functionTypeExpected) {
|
||||
effectiveReceiverType = JetStandardClasses.getReceiverType(context.expectedType);
|
||||
effectiveReceiverType = KotlinBuiltIns.getInstance().getReceiverType(context.expectedType);
|
||||
}
|
||||
else {
|
||||
effectiveReceiverType = null;
|
||||
@@ -185,7 +185,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
List<JetParameter> declaredValueParameters = functionLiteral.getValueParameters();
|
||||
|
||||
List<ValueParameterDescriptor> expectedValueParameters = (functionTypeExpected)
|
||||
? JetStandardClasses.getValueParameters(functionDescriptor, context.expectedType)
|
||||
? KotlinBuiltIns.getInstance().getValueParameters(functionDescriptor, context.expectedType)
|
||||
: null;
|
||||
|
||||
boolean hasDeclaredValueParameters = functionLiteral.getValueParameterList() != null;
|
||||
|
||||
+15
-15
@@ -42,7 +42,7 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||
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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
|
||||
@@ -100,12 +100,12 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetTypeInfo typeInfo = context.expressionTypingServices.getBlockReturnedTypeWithWritableScope(thenScope, Collections.singletonList(thenBranch), CoercionStrategy.NO_COERCION, context.replaceDataFlowInfo(thenInfo), context.trace);
|
||||
JetType type = typeInfo.getType();
|
||||
DataFlowInfo dataFlowInfo;
|
||||
if (type != null && JetStandardClasses.isNothing(type)) {
|
||||
if (type != null && KotlinBuiltIns.getInstance().isNothing(type)) {
|
||||
dataFlowInfo = elseInfo;
|
||||
} else {
|
||||
dataFlowInfo = typeInfo.getDataFlowInfo().or(elseInfo);
|
||||
}
|
||||
return DataFlowUtils.checkImplicitCast(DataFlowUtils.checkType(JetStandardClasses.getUnitType(), expression, contextWithExpectedType), expression, contextWithExpectedType, isStatement, dataFlowInfo);
|
||||
return DataFlowUtils.checkImplicitCast(DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getUnitType(), expression, contextWithExpectedType), expression, contextWithExpectedType, isStatement, dataFlowInfo);
|
||||
}
|
||||
return JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
}
|
||||
@@ -113,12 +113,12 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetTypeInfo typeInfo = context.expressionTypingServices.getBlockReturnedTypeWithWritableScope(elseScope, Collections.singletonList(elseBranch), CoercionStrategy.NO_COERCION, context.replaceDataFlowInfo(elseInfo), context.trace);
|
||||
JetType type = typeInfo.getType();
|
||||
DataFlowInfo dataFlowInfo;
|
||||
if (type != null && JetStandardClasses.isNothing(type)) {
|
||||
if (type != null && KotlinBuiltIns.getInstance().isNothing(type)) {
|
||||
dataFlowInfo = thenInfo;
|
||||
} else {
|
||||
dataFlowInfo = typeInfo.getDataFlowInfo().or(thenInfo);
|
||||
}
|
||||
return DataFlowUtils.checkImplicitCast(DataFlowUtils.checkType(JetStandardClasses.getUnitType(), expression, contextWithExpectedType), expression, contextWithExpectedType, isStatement, dataFlowInfo);
|
||||
return DataFlowUtils.checkImplicitCast(DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getUnitType(), expression, contextWithExpectedType), expression, contextWithExpectedType, isStatement, dataFlowInfo);
|
||||
}
|
||||
CoercionStrategy coercionStrategy = isStatement ? CoercionStrategy.COERCION_TO_UNIT : CoercionStrategy.NO_COERCION;
|
||||
JetTypeInfo thenTypeInfo = context.expressionTypingServices.getBlockReturnedTypeWithWritableScope(thenScope, Collections.singletonList(thenBranch), coercionStrategy, contextWithExpectedType.replaceDataFlowInfo(thenInfo), context.trace);
|
||||
@@ -128,8 +128,8 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
DataFlowInfo thenDataFlowInfo = thenTypeInfo.getDataFlowInfo();
|
||||
DataFlowInfo elseDataFlowInfo = elseTypeInfo.getDataFlowInfo();
|
||||
|
||||
boolean jumpInThen = thenType != null && JetStandardClasses.isNothing(thenType);
|
||||
boolean jumpInElse = elseType != null && JetStandardClasses.isNothing(elseType);
|
||||
boolean jumpInThen = thenType != null && KotlinBuiltIns.getInstance().isNothing(thenType);
|
||||
boolean jumpInElse = elseType != null && KotlinBuiltIns.getInstance().isNothing(elseType);
|
||||
|
||||
JetTypeInfo result;
|
||||
if (thenType == null && elseType == null) {
|
||||
@@ -172,7 +172,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
else {
|
||||
dataFlowInfo = context.dataFlowInfo;
|
||||
}
|
||||
return DataFlowUtils.checkType(JetStandardClasses.getUnitType(), expression, contextWithExpectedType, dataFlowInfo);
|
||||
return DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getUnitType(), expression, contextWithExpectedType, dataFlowInfo);
|
||||
}
|
||||
|
||||
private boolean containsBreak(final JetLoopExpression loopExpression, final ExpressionTypingContext context) {
|
||||
@@ -242,7 +242,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
else {
|
||||
dataFlowInfo = context.dataFlowInfo;
|
||||
}
|
||||
return DataFlowUtils.checkType(JetStandardClasses.getUnitType(), expression, contextWithExpectedType, dataFlowInfo);
|
||||
return DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getUnitType(), expression, contextWithExpectedType, dataFlowInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -285,7 +285,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
context.expressionTypingServices.getBlockReturnedTypeWithWritableScope(loopScope, Collections.singletonList(body), CoercionStrategy.NO_COERCION, context, context.trace);
|
||||
}
|
||||
|
||||
return DataFlowUtils.checkType(JetStandardClasses.getUnitType(), expression, contextWithExpectedType, context.dataFlowInfo);
|
||||
return DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getUnitType(), expression, contextWithExpectedType, context.dataFlowInfo);
|
||||
}
|
||||
|
||||
private static VariableDescriptor createLoopParameterDescriptor(
|
||||
@@ -442,7 +442,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetType throwableType = JetStandardLibrary.getInstance().getThrowable().getDefaultType();
|
||||
facade.getTypeInfo(thrownExpression, context.replaceExpectedType(throwableType).replaceScope(context.scope));
|
||||
}
|
||||
return DataFlowUtils.checkType(JetStandardClasses.getNothingType(), expression, context, context.dataFlowInfo);
|
||||
return DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getNothingType(), expression, context, context.dataFlowInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -498,22 +498,22 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
facade.getTypeInfo(returnedExpression, context.replaceExpectedType(expectedType).replaceScope(context.scope));
|
||||
}
|
||||
else {
|
||||
if (expectedType != TypeUtils.NO_EXPECTED_TYPE && expectedType != null && !JetStandardClasses.isUnit(expectedType)) {
|
||||
if (expectedType != TypeUtils.NO_EXPECTED_TYPE && expectedType != null && !KotlinBuiltIns.getInstance().isUnit(expectedType)) {
|
||||
context.trace.report(RETURN_TYPE_MISMATCH.on(expression, expectedType));
|
||||
}
|
||||
}
|
||||
return DataFlowUtils.checkType(JetStandardClasses.getNothingType(), expression, context, context.dataFlowInfo);
|
||||
return DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getNothingType(), expression, context, context.dataFlowInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetTypeInfo visitBreakExpression(JetBreakExpression expression, ExpressionTypingContext context) {
|
||||
context.labelResolver.resolveLabel(expression, context);
|
||||
return DataFlowUtils.checkType(JetStandardClasses.getNothingType(), expression, context, context.dataFlowInfo);
|
||||
return DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getNothingType(), expression, context, context.dataFlowInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetTypeInfo visitContinueExpression(JetContinueExpression expression, ExpressionTypingContext context) {
|
||||
context.labelResolver.resolveLabel(expression, context);
|
||||
return DataFlowUtils.checkType(JetStandardClasses.getNothingType(), expression, context, context.dataFlowInfo);
|
||||
return DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getNothingType(), expression, context, context.dataFlowInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.JetTypeInfo;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
@@ -168,11 +168,11 @@ public class DataFlowUtils {
|
||||
|
||||
@Nullable
|
||||
public static JetType checkStatementType(@NotNull JetExpression expression, @NotNull ExpressionTypingContext context) {
|
||||
if (context.expectedType != TypeUtils.NO_EXPECTED_TYPE && !JetStandardClasses.isUnit(context.expectedType) && !ErrorUtils.isErrorType(context.expectedType)) {
|
||||
if (context.expectedType != TypeUtils.NO_EXPECTED_TYPE && !KotlinBuiltIns.getInstance().isUnit(context.expectedType) && !ErrorUtils.isErrorType(context.expectedType)) {
|
||||
context.trace.report(EXPECTED_TYPE_MISMATCH.on(expression, context.expectedType));
|
||||
return null;
|
||||
}
|
||||
return JetStandardClasses.getUnitType();
|
||||
return KotlinBuiltIns.getInstance().getUnitType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -183,7 +183,7 @@ public class DataFlowUtils {
|
||||
@Nullable
|
||||
public static JetType checkImplicitCast(@Nullable JetType expressionType, @NotNull JetExpression expression, @NotNull ExpressionTypingContext context, boolean isStatement) {
|
||||
if (expressionType != null && context.expectedType == TypeUtils.NO_EXPECTED_TYPE && !isStatement &&
|
||||
(JetStandardClasses.isUnit(expressionType) || JetStandardClasses.isAny(expressionType))) {
|
||||
(KotlinBuiltIns.getInstance().isUnit(expressionType) || KotlinBuiltIns.getInstance().isAny(expressionType))) {
|
||||
context.trace.report(IMPLICIT_CAST_TO_UNIT_OR_ANY.on(expression, expressionType));
|
||||
|
||||
}
|
||||
|
||||
+7
-7
@@ -39,7 +39,7 @@ import org.jetbrains.jet.lang.types.CommonSupertypes;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.JetTypeInfo;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -142,7 +142,7 @@ public class ExpressionTypingServices {
|
||||
Map<JetExpression, JetType> typeMap = collectReturnedExpressionsWithTypes(trace, outerScope, function, functionDescriptor);
|
||||
Collection<JetType> types = typeMap.values();
|
||||
return types.isEmpty()
|
||||
? JetStandardClasses.getNothingType()
|
||||
? KotlinBuiltIns.getInstance().getNothingType()
|
||||
: CommonSupertypes.commonSupertype(types);
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ public class ExpressionTypingServices {
|
||||
|
||||
JetTypeInfo r;
|
||||
if (block.isEmpty()) {
|
||||
r = DataFlowUtils.checkType(JetStandardClasses.getUnitType(), expression, context, context.dataFlowInfo);
|
||||
r = DataFlowUtils.checkType(KotlinBuiltIns.getInstance().getUnitType(), expression, context, context.dataFlowInfo);
|
||||
}
|
||||
else {
|
||||
r = getBlockReturnedTypeWithWritableScope(scope, block, coercionStrategyForLastExpression, context, trace);
|
||||
@@ -272,7 +272,7 @@ public class ExpressionTypingServices {
|
||||
@SuppressWarnings("SuspiciousMethodCalls")
|
||||
JetTypeInfo getBlockReturnedTypeWithWritableScope(@NotNull WritableScope scope, @NotNull List<? extends JetElement> block, @NotNull CoercionStrategy coercionStrategyForLastExpression, ExpressionTypingContext context, BindingTrace trace) {
|
||||
if (block.isEmpty()) {
|
||||
return JetTypeInfo.create(JetStandardClasses.getUnitType(), context.dataFlowInfo);
|
||||
return JetTypeInfo.create(KotlinBuiltIns.getInstance().getUnitType(), context.dataFlowInfo);
|
||||
}
|
||||
|
||||
ExpressionTypingInternals blockLevelVisitor = ExpressionTypingVisitorDispatcher.createForBlock(scope);
|
||||
@@ -289,7 +289,7 @@ public class ExpressionTypingServices {
|
||||
//TODO constructor assert context.expectedType != FORBIDDEN : ""
|
||||
if (!iterator.hasNext()) {
|
||||
if (context.expectedType != NO_EXPECTED_TYPE) {
|
||||
if (coercionStrategyForLastExpression == CoercionStrategy.COERCION_TO_UNIT && JetStandardClasses.isUnit(context.expectedType)) {
|
||||
if (coercionStrategyForLastExpression == CoercionStrategy.COERCION_TO_UNIT && KotlinBuiltIns.getInstance().isUnit(context.expectedType)) {
|
||||
// This implements coercion to Unit
|
||||
TemporaryBindingTrace temporaryTraceExpectingUnit = TemporaryBindingTrace.create(trace);
|
||||
final boolean[] mismatch = new boolean[1];
|
||||
@@ -334,8 +334,8 @@ public class ExpressionTypingServices {
|
||||
}
|
||||
if (mightBeUnit) {
|
||||
// ExpressionTypingVisitorForStatements should return only null or Unit for declarations and assignments
|
||||
assert result.getType() == null || JetStandardClasses.isUnit(result.getType());
|
||||
result = JetTypeInfo.create(JetStandardClasses.getUnitType(), newContext.dataFlowInfo);
|
||||
assert result.getType() == null || KotlinBuiltIns.getInstance().isUnit(result.getType());
|
||||
result = JetTypeInfo.create(KotlinBuiltIns.getInstance().getUnitType(), newContext.dataFlowInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||
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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
|
||||
@@ -121,7 +121,7 @@ public class ExpressionTypingUtils {
|
||||
return JetStandardLibrary.getInstance().getCharType();
|
||||
}
|
||||
else if (constantType == JetNodeTypes.NULL) {
|
||||
return JetStandardClasses.getNullableNothingType();
|
||||
return KotlinBuiltIns.getInstance().getNullableNothingType();
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Unsupported constant type: " + constantType);
|
||||
|
||||
+3
-3
@@ -33,7 +33,7 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.jet.lang.types.JetTypeInfo;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
@@ -69,7 +69,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
||||
|
||||
@Nullable
|
||||
private JetType checkAssignmentType(@Nullable JetType assignmentType, @NotNull JetBinaryExpression expression, @NotNull ExpressionTypingContext context) {
|
||||
if (assignmentType != null && !JetStandardClasses.isUnit(assignmentType) && context.expectedType != TypeUtils.NO_EXPECTED_TYPE &&
|
||||
if (assignmentType != null && !KotlinBuiltIns.getInstance().isUnit(assignmentType) && context.expectedType != TypeUtils.NO_EXPECTED_TYPE &&
|
||||
TypeUtils.equalTypes(context.expectedType, assignmentType)) {
|
||||
context.trace.report(Errors.ASSIGNMENT_TYPE_MISMATCH.on(expression, context.expectedType));
|
||||
return null;
|
||||
@@ -243,7 +243,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
||||
}
|
||||
else if (assignmentOperationType != null) {
|
||||
assignmentOperationTrace.commit();
|
||||
if (!JetStandardClasses.isUnit(assignmentOperationType)) {
|
||||
if (!KotlinBuiltIns.getInstance().isUnit(assignmentOperationType)) {
|
||||
context.trace.report(ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT.on(operationSign, assignmentOperationDescriptors.getResultingDescriptor(), operationSign));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValueFactory;
|
||||
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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -294,7 +294,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
|
||||
// check if the pattern is essentially a 'null' expression
|
||||
if (type == JetStandardClasses.getNullableNothingType() && !subjectType.isNullable()) {
|
||||
if (type == KotlinBuiltIns.getInstance().getNullableNothingType() && !subjectType.isNullable()) {
|
||||
context.trace.report(SENSELESS_NULL_IN_WHEN.on(reportErrorOn));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,9 +49,10 @@ public enum PrimitiveType {
|
||||
this.typeName = Name.identifier(typeName);
|
||||
this.arrayTypeName = Name.identifier(typeName + "Array");
|
||||
this.rangeTypeName = Name.identifier(typeName + "Range");
|
||||
this.className = JetStandardClasses.STANDARD_CLASSES_FQNAME.child(this.typeName);
|
||||
this.arrayClassName = JetStandardClasses.STANDARD_CLASSES_FQNAME.child(this.arrayTypeName);
|
||||
this.rangeClassName = JetStandardClasses.STANDARD_CLASSES_FQNAME.child(this.rangeTypeName);
|
||||
FqName builtInsPackageFqName = KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME;
|
||||
this.className = builtInsPackageFqName.child(this.typeName);
|
||||
this.arrayClassName = builtInsPackageFqName.child(this.arrayTypeName);
|
||||
this.rangeClassName = builtInsPackageFqName.child(this.rangeTypeName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeProjection;
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.*;
|
||||
@@ -113,13 +113,13 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
|
||||
else if (ErrorUtils.isErrorType(type)) {
|
||||
return escape(type.toString());
|
||||
}
|
||||
else if (JetStandardClasses.isUnit(type)) {
|
||||
return escape(JetStandardClasses.UNIT_ALIAS + (type.isNullable() ? "?" : ""));
|
||||
else if (KotlinBuiltIns.getInstance().isUnit(type)) {
|
||||
return escape(KotlinBuiltIns.getInstance().UNIT_ALIAS + (type.isNullable() ? "?" : ""));
|
||||
}
|
||||
else if (JetStandardClasses.isTupleType(type)) {
|
||||
else if (KotlinBuiltIns.getInstance().isTupleType(type)) {
|
||||
return escape(renderTupleType(type, shortNamesOnly));
|
||||
}
|
||||
else if (JetStandardClasses.isFunctionType(type)) {
|
||||
else if (KotlinBuiltIns.getInstance().isFunctionType(type)) {
|
||||
return escape(renderFunctionType(type, shortNamesOnly));
|
||||
}
|
||||
else {
|
||||
@@ -196,7 +196,7 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
|
||||
|
||||
protected String renderTupleType(JetType type, boolean shortNamesOnly) {
|
||||
StringBuilder sb = new StringBuilder("#(");
|
||||
appendTypes(sb, JetStandardClasses.getTupleElementTypes(type), shortNamesOnly);
|
||||
appendTypes(sb, KotlinBuiltIns.getInstance().getTupleElementTypes(type), shortNamesOnly);
|
||||
sb.append(")");
|
||||
|
||||
if (type.isNullable()) {
|
||||
@@ -209,16 +209,16 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
|
||||
private String renderFunctionType(JetType type, boolean shortNamesOnly) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
JetType receiverType = JetStandardClasses.getReceiverType(type);
|
||||
JetType receiverType = KotlinBuiltIns.getInstance().getReceiverType(type);
|
||||
if (receiverType != null) {
|
||||
sb.append(renderType(receiverType, shortNamesOnly));
|
||||
sb.append(".");
|
||||
}
|
||||
|
||||
sb.append("(");
|
||||
appendTypeProjections(sb, JetStandardClasses.getParameterTypeProjectionsFromFunctionType(type), shortNamesOnly);
|
||||
appendTypeProjections(sb, KotlinBuiltIns.getInstance().getParameterTypeProjectionsFromFunctionType(type), shortNamesOnly);
|
||||
sb.append(") -> ");
|
||||
sb.append(renderType(JetStandardClasses.getReturnTypeFromFunctionType(type), shortNamesOnly));
|
||||
sb.append(renderType(KotlinBuiltIns.getInstance().getReturnTypeFromFunctionType(type), shortNamesOnly));
|
||||
|
||||
if (type.isNullable()) {
|
||||
return "(" + sb + ")?";
|
||||
@@ -565,9 +565,9 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
|
||||
renderName(descriptor, builder);
|
||||
renderTypeParameters(descriptor.getTypeConstructor().getParameters(), builder);
|
||||
}
|
||||
if (!descriptor.equals(JetStandardClasses.getNothing())) {
|
||||
if (!descriptor.equals(KotlinBuiltIns.getInstance().getNothing())) {
|
||||
Collection<? extends JetType> supertypes = descriptor.getTypeConstructor().getSupertypes();
|
||||
if (supertypes.isEmpty() || supertypes.size() == 1 && JetStandardClasses.isAny(supertypes.iterator().next())) {
|
||||
if (supertypes.isEmpty() || supertypes.size() == 1 && KotlinBuiltIns.getInstance().isAny(supertypes.iterator().next())) {
|
||||
}
|
||||
else {
|
||||
builder.append(" : ");
|
||||
@@ -599,14 +599,14 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
|
||||
renderName(descriptor, builder);
|
||||
if (descriptor.getUpperBounds().size() == 1) {
|
||||
JetType upperBound = descriptor.getUpperBounds().iterator().next();
|
||||
if (upperBound != JetStandardClasses.getDefaultBound()) {
|
||||
if (upperBound != KotlinBuiltIns.getInstance().getDefaultBound()) {
|
||||
builder.append(" : ").append(renderType(upperBound));
|
||||
}
|
||||
}
|
||||
else if (topLevel) {
|
||||
boolean first = true;
|
||||
for (JetType upperBound : descriptor.getUpperBounds()) {
|
||||
if (upperBound.equals(JetStandardClasses.getDefaultBound())) {
|
||||
if (upperBound.equals(KotlinBuiltIns.getInstance().getDefaultBound())) {
|
||||
continue;
|
||||
}
|
||||
if (first) {
|
||||
|
||||
@@ -51,7 +51,7 @@ import org.jetbrains.jet.lang.resolve.java.JetFilesProvider;
|
||||
import org.jetbrains.jet.lang.resolve.java.JetJavaMirrorMarker;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -94,7 +94,7 @@ public class JetLightClass extends AbstractLightClass implements JetJavaMirrorMa
|
||||
|
||||
@Nullable
|
||||
public static JetLightClass create(PsiManager manager, JetFile file, FqName qualifiedName) {
|
||||
return JetStandardClasses.isStandardClass(qualifiedName) ? null : new JetLightClass(manager, file, qualifiedName);
|
||||
return KotlinBuiltIns.getInstance().isStandardClass(qualifiedName) ? null : new JetLightClass(manager, file, qualifiedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeProjection;
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.junit.Assert;
|
||||
import org.junit.ComparisonFailure;
|
||||
|
||||
@@ -732,7 +732,7 @@ public class NamespaceComparator {
|
||||
sb.append(">");
|
||||
}
|
||||
|
||||
if (JetStandardClasses.getNothing() != klass && !klass.getTypeConstructor().getSupertypes().isEmpty()) {
|
||||
if (KotlinBuiltIns.getInstance().getNothing() != klass && !klass.getTypeConstructor().getSupertypes().isEmpty()) {
|
||||
sb.append(" : ");
|
||||
new TypeSerializer(sb).serializeCommaSeparated(new ArrayList<JetType>(klass.getTypeConstructor().getSupertypes()));
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ 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.expressions.ExpressionTypingServices;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
@@ -117,15 +117,15 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
||||
assertType("\"d\"", library.getStringType());
|
||||
assertType("\"\"\"d\"\"\"", library.getStringType());
|
||||
|
||||
assertType("#()", JetStandardClasses.getUnitType());
|
||||
assertType("#()", KotlinBuiltIns.getInstance().getUnitType());
|
||||
|
||||
assertType("null", JetStandardClasses.getNullableNothingType());
|
||||
assertType("null", KotlinBuiltIns.getInstance().getNullableNothingType());
|
||||
}
|
||||
|
||||
public void testTupleConstants() throws Exception {
|
||||
assertType("#()", JetStandardClasses.getUnitType());
|
||||
assertType("#()", KotlinBuiltIns.getInstance().getUnitType());
|
||||
|
||||
assertType("#(1, 'a')", JetStandardClasses.getTupleType(library.getIntType(), library.getCharType()));
|
||||
assertType("#(1, 'a')", KotlinBuiltIns.getInstance().getTupleType(library.getIntType(), library.getCharType()));
|
||||
}
|
||||
|
||||
public void testTypeInfo() throws Exception {
|
||||
@@ -135,9 +135,9 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
||||
}
|
||||
|
||||
public void testJumps() throws Exception {
|
||||
assertType("throw java.lang.Exception()", JetStandardClasses.getNothingType());
|
||||
assertType("continue", JetStandardClasses.getNothingType());
|
||||
assertType("break", JetStandardClasses.getNothingType());
|
||||
assertType("throw java.lang.Exception()", KotlinBuiltIns.getInstance().getNothingType());
|
||||
assertType("continue", KotlinBuiltIns.getInstance().getNothingType());
|
||||
assertType("break", KotlinBuiltIns.getInstance().getNothingType());
|
||||
}
|
||||
|
||||
public void testIf() throws Exception {
|
||||
@@ -713,7 +713,7 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
||||
List<JetDelegationSpecifier> delegationSpecifiers = classElement.getDelegationSpecifiers();
|
||||
// TODO : assuming that the hierarchy is acyclic
|
||||
Collection<JetType> supertypes = delegationSpecifiers.isEmpty()
|
||||
? Collections.singleton(JetStandardClasses.getAnyType())
|
||||
? Collections.singleton(KotlinBuiltIns.getInstance().getAnyType())
|
||||
: descriptorResolver.resolveDelegationSpecifiers(parameterScope, delegationSpecifiers, typeResolver, JetTestUtils.DUMMY_TRACE, true);
|
||||
// for (JetType supertype: supertypes) {
|
||||
// if (supertype.getConstructor().isSealed()) {
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.LinkedList;
|
||||
@@ -54,8 +54,8 @@ public class JetPluginUtil {
|
||||
}
|
||||
|
||||
public static boolean checkTypeIsStandard(JetType type, Project project) {
|
||||
if (JetStandardClasses.isAny(type) || JetStandardClasses.isNothingOrNullableNothing(type) || JetStandardClasses.isUnit(type) ||
|
||||
JetStandardClasses.isTupleType(type) || JetStandardClasses.isFunctionType(type)) {
|
||||
if (KotlinBuiltIns.getInstance().isAny(type) || KotlinBuiltIns.getInstance().isNothingOrNullableNothing(type) || KotlinBuiltIns.getInstance().isUnit(type) ||
|
||||
KotlinBuiltIns.getInstance().isTupleType(type) || KotlinBuiltIns.getInstance().isFunctionType(type)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,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.expressions.ExpressionTypingUtils;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
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;
|
||||
@@ -120,7 +120,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
||||
*/
|
||||
@NotNull
|
||||
public static Collection<DeclarationDescriptor> getJetOnlyTypes() {
|
||||
Collection<DeclarationDescriptor> standardTypes = JetStandardClasses.getAllStandardClasses();
|
||||
Collection<DeclarationDescriptor> standardTypes = KotlinBuiltIns.getInstance().getAllBuiltInClasses();
|
||||
standardTypes.addAll(
|
||||
Collections2.transform(JetStandardLibrary.getInstance().getStandardTypes(),
|
||||
new Function<ClassDescriptor, DeclarationDescriptor>() {
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
import org.jetbrains.jet.plugin.project.WholeProjectAnalyzerFacade;
|
||||
|
||||
@@ -99,7 +99,7 @@ public class GotoSuperActionHandler implements CodeInsightActionHandler {
|
||||
List<PsiElement> superDeclarations = ContainerUtil.mapNotNull(superDescriptors, new Function<DeclarationDescriptor, PsiElement>() {
|
||||
@Override
|
||||
public PsiElement fun(DeclarationDescriptor descriptor) {
|
||||
if (JetStandardClasses.getAny() == descriptor) {
|
||||
if (KotlinBuiltIns.getInstance().getAny() == descriptor) {
|
||||
return null;
|
||||
}
|
||||
return BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor);
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.jet.lang.psi.*;
|
||||
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.JetStandardClasses;
|
||||
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;
|
||||
@@ -177,7 +177,7 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
|
||||
boolean firstUpperBound = true;
|
||||
for (JetType upperBound : upperBounds) {
|
||||
String upperBoundText = " : " + renderType(upperBound);
|
||||
if (upperBound != JetStandardClasses.getDefaultBound()) {
|
||||
if (upperBound != KotlinBuiltIns.getInstance().getDefaultBound()) {
|
||||
if (firstUpperBound) {
|
||||
bodyBuilder.append(upperBoundText);
|
||||
} else {
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.plugin.project.WholeProjectAnalyzerFacade;
|
||||
import org.jetbrains.jet.plugin.quickfix.ImportInsertHelper;
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ReferenceToClassesShortening {
|
||||
}
|
||||
|
||||
private void compactReferenceToClass(JetUserType userType, ClassDescriptor targetClass) {
|
||||
if (targetClass == JetStandardClasses.getUnitType().getConstructor().getDeclarationDescriptor()) {
|
||||
if (targetClass == KotlinBuiltIns.getInstance().getUnitType().getConstructor().getDeclarationDescriptor()) {
|
||||
// do not replace "Unit" with "Tuple0"
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.plugin.JetDescriptorIconProvider;
|
||||
import org.jetbrains.jet.plugin.completion.handlers.JetClassInsertHandler;
|
||||
import org.jetbrains.jet.plugin.completion.handlers.JetFunctionInsertHandler;
|
||||
@@ -85,7 +85,7 @@ public final class DescriptorLookupConverter {
|
||||
}
|
||||
else {
|
||||
if (functionDescriptor.getValueParameters().size() == 1
|
||||
&& JetStandardClasses.isFunctionType(functionDescriptor.getValueParameters().get(0).getType())) {
|
||||
&& KotlinBuiltIns.getInstance().isFunctionType(functionDescriptor.getValueParameters().get(0).getType())) {
|
||||
element = element.withInsertHandler(PARAMS_BRACES_FUNCTION_HANDLER);
|
||||
} else {
|
||||
element = element.withInsertHandler(PARAMS_PARENTHESIS_FUNCTION_HANDLER);
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BodiesResolveContext;
|
||||
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeProvider;
|
||||
import org.jetbrains.jet.plugin.project.PluginJetFilesProvider;
|
||||
@@ -119,7 +119,7 @@ public class MigrateTuplesInProjectFix extends JetIntentionAction<PsiElement> {
|
||||
if (containingDeclaration == null) return;
|
||||
|
||||
ImmutableSet<ClassDescriptor> supportedTupleClasses =
|
||||
ImmutableSet.of(JetStandardClasses.getTuple(2), JetStandardClasses.getTuple(3));
|
||||
ImmutableSet.of(KotlinBuiltIns.getInstance().getTuple(2), KotlinBuiltIns.getInstance().getTuple(3));
|
||||
//noinspection SuspiciousMethodCalls
|
||||
if (!supportedTupleClasses.contains(containingDeclaration)) return;
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.plugin.references;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.components.AbstractProjectComponent;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
@@ -41,7 +40,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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
import java.net.URL;
|
||||
@@ -54,7 +53,7 @@ public class StandardLibraryReferenceResolver extends AbstractProjectComponent {
|
||||
private BindingContext bindingContext = null;
|
||||
|
||||
private final Object lock = new Object();
|
||||
private static final FqName TUPLE0_FQ_NAME = DescriptorUtils.getFQName(JetStandardClasses.getTuple(0)).toSafe();
|
||||
private static final FqName TUPLE0_FQ_NAME = DescriptorUtils.getFQName(KotlinBuiltIns.getInstance().getTuple(0)).toSafe();
|
||||
|
||||
public StandardLibraryReferenceResolver(Project project) {
|
||||
super(project);
|
||||
@@ -78,7 +77,7 @@ public class StandardLibraryReferenceResolver extends AbstractProjectComponent {
|
||||
|
||||
BindingTraceContext context = new BindingTraceContext();
|
||||
FakeJetNamespaceDescriptor jetNamespace = new FakeJetNamespaceDescriptor();
|
||||
context.record(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, JetStandardClasses.STANDARD_CLASSES_FQNAME, jetNamespace);
|
||||
context.record(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, KotlinBuiltIns.getInstance().getBuiltInsPackageFqName(), jetNamespace);
|
||||
|
||||
WritableScopeImpl scope = new WritableScopeImpl(JetScope.EMPTY, jetNamespace, RedeclarationHandler.THROW_EXCEPTION,
|
||||
"Builtin classes scope");
|
||||
@@ -92,7 +91,7 @@ public class StandardLibraryReferenceResolver extends AbstractProjectComponent {
|
||||
scope = new WritableScopeImpl(scope, jetNamespace, RedeclarationHandler.THROW_EXCEPTION,
|
||||
"Builtin classes scope: needed to analyze builtins which depend on Unit type alias");
|
||||
scope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||
scope.addClassifierAlias(JetStandardClasses.UNIT_ALIAS, tuple0);
|
||||
scope.addClassifierAlias(KotlinBuiltIns.getInstance().UNIT_ALIAS, tuple0);
|
||||
jetNamespace.setMemberScope(scope);
|
||||
|
||||
TopDownAnalyzer.processStandardLibraryNamespace(myProject, context, scope, jetNamespace, getJetFiles("jet"));
|
||||
@@ -145,7 +144,7 @@ public class StandardLibraryReferenceResolver extends AbstractProjectComponent {
|
||||
}
|
||||
for (DeclarationDescriptor member : descriptors) {
|
||||
if (renderedOriginal.equals(DescriptorRenderer.TEXT.render(member).replace(TUPLE0_FQ_NAME.getFqName(),
|
||||
JetStandardClasses.UNIT_ALIAS.getName()))) {
|
||||
KotlinBuiltIns.getInstance().UNIT_ALIAS.getName()))) {
|
||||
return member;
|
||||
}
|
||||
}
|
||||
@@ -211,7 +210,7 @@ public class StandardLibraryReferenceResolver extends AbstractProjectComponent {
|
||||
super(new NamespaceDescriptorImpl(new ModuleDescriptor(Name.special("<fake_module>")),
|
||||
Collections.<AnnotationDescriptor>emptyList(), Name.special("<root>")),
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
JetStandardClasses.STANDARD_CLASSES_NAMESPACE.getName());
|
||||
KotlinBuiltIns.getInstance().getBuiltInsPackage().getName());
|
||||
}
|
||||
|
||||
void setMemberScope(WritableScope memberScope) {
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorVisitorEmptyBodies;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -81,7 +81,7 @@ public class StandardLibraryReferenceResolverTest extends ResolveTestCase {
|
||||
|
||||
public void testAllReferencesResolved() {
|
||||
StandardLibraryReferenceResolver referenceResolver = getProject().getComponent(StandardLibraryReferenceResolver.class);
|
||||
for (DeclarationDescriptor descriptor : getAllStandardDescriptors(JetStandardClasses.STANDARD_CLASSES_NAMESPACE)) {
|
||||
for (DeclarationDescriptor descriptor : getAllStandardDescriptors(KotlinBuiltIns.getInstance().getBuiltInsPackage())) {
|
||||
if (descriptor instanceof NamespaceDescriptor && "jet".equals(descriptor.getName().getName())) continue;
|
||||
assertNotNull("Can't resolve " + descriptor, referenceResolver.resolveStandardLibrarySymbol(descriptor));
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.jet.j2k.Converter;
|
||||
import org.jetbrains.jet.j2k.J2KConverterFlags;
|
||||
import org.jetbrains.jet.j2k.ast.*;
|
||||
import org.jetbrains.jet.j2k.util.AstUtil;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -62,7 +62,7 @@ public class TypeVisitor extends PsiTypeVisitor<Type> implements J2KVisitor {
|
||||
final IdentifierImpl identifier = new IdentifierImpl(name);
|
||||
|
||||
if (name.equals("void")) {
|
||||
myResult = new PrimitiveType(new IdentifierImpl(JetStandardClasses.UNIT_ALIAS.getName()));
|
||||
myResult = new PrimitiveType(new IdentifierImpl(KotlinBuiltIns.getInstance().UNIT_ALIAS.getName()));
|
||||
}
|
||||
else if (Node.PRIMITIVE_TYPES.contains(name)) {
|
||||
myResult = new PrimitiveType(new IdentifierImpl(AstUtil.upperFirstCharacter(name)));
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -51,7 +51,7 @@ public class JsConfiguration implements ModuleConfiguration {
|
||||
public static final List<ImportPath> DEFAULT_IMPORT_PATHS = Arrays.asList(
|
||||
new ImportPath("js.*"),
|
||||
new ImportPath("java.lang.*"),
|
||||
new ImportPath(JetStandardClasses.STANDARD_CLASSES_FQNAME, true),
|
||||
new ImportPath(KotlinBuiltIns.getInstance().getBuiltInsPackageFqName(), true),
|
||||
new ImportPath("kotlin.*"));
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetDeclarationWithBody;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.k2js.translate.context.TranslationContext;
|
||||
import org.jetbrains.k2js.translate.general.AbstractTranslator;
|
||||
import org.jetbrains.k2js.translate.general.Translation;
|
||||
@@ -78,7 +78,7 @@ public final class FunctionBodyTranslator extends AbstractTranslator {
|
||||
private boolean mustAddReturnToGeneratedFunctionBody() {
|
||||
JetType functionReturnType = descriptor.getReturnType();
|
||||
assert functionReturnType != null : "Function return typed type must be resolved.";
|
||||
return (!declaration.hasBlockBody()) && (!JetStandardClasses.isUnit(functionReturnType));
|
||||
return (!declaration.hasBlockBody()) && (!KotlinBuiltIns.getInstance().isUnit(functionReturnType));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver;
|
||||
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.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.k2js.translate.context.TranslationContext;
|
||||
|
||||
@@ -175,7 +175,7 @@ public final class JsDescriptorUtils {
|
||||
@Nullable
|
||||
public static Name getNameIfStandardType(@NotNull JetType type) {
|
||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
if (descriptor != null && descriptor.getContainingDeclaration() == JetStandardClasses.STANDARD_CLASSES_NAMESPACE) {
|
||||
if (descriptor != null && descriptor.getContainingDeclaration() == KotlinBuiltIns.getInstance().getBuiltInsPackage()) {
|
||||
return descriptor.getName();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user