JetStandardClasses -> KotlinBuiltIns
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user