From 0388171d88a490b01b88b3d74d34acb500b174b6 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 15 Mar 2011 13:46:40 +0300 Subject: [PATCH] s/Type/JetType/ --- .../jet/codegen/FunctionCodegen.java | 9 +- .../org/jetbrains/jet/lang/ErrorHandler.java | 6 +- .../jet/lang/annotations/JetPsiChecker.java | 6 +- .../jet/lang/resolve/BindingContext.java | 4 +- .../jet/lang/resolve/BindingTraceContext.java | 12 +-- .../lang/resolve/ClassDescriptorResolver.java | 20 ++--- .../jetbrains/jet/lang/resolve/JetScope.java | 2 +- .../jet/lang/resolve/JetScopeAdapter.java | 2 +- .../jet/lang/resolve/JetScopeImpl.java | 2 +- .../jet/lang/resolve/OverloadDomain.java | 16 ++-- .../jet/lang/resolve/OverloadResolver.java | 22 ++--- .../jet/lang/resolve/ScopeWithReceiver.java | 4 +- .../jet/lang/resolve/SubstitutingScope.java | 2 +- .../jet/lang/resolve/TopDownAnalyzer.java | 2 +- .../jet/lang/resolve/TypeResolver.java | 28 +++---- .../lang/resolve/WritableFunctionGroup.java | 2 +- .../jet/lang/resolve/WritableScope.java | 6 +- .../resolve/java/JavaClassMembersScope.java | 2 +- .../resolve/java/JavaDescriptorResolver.java | 8 +- .../resolve/java/JavaTypeTransformer.java | 24 +++--- .../jet/lang/types/BindingTrace.java | 4 +- .../jet/lang/types/ClassDescriptorImpl.java | 2 +- .../jet/lang/types/DfsNodeHandler.java | 4 +- .../jetbrains/jet/lang/types/ErrorType.java | 14 ++-- .../jet/lang/types/FunctionDescriptor.java | 2 +- .../lang/types/FunctionDescriptorImpl.java | 6 +- .../lang/types/FunctionDescriptorUtil.java | 10 +-- .../jet/lang/types/FunctionGroup.java | 4 +- .../jet/lang/types/JetStandardClasses.java | 58 ++++++------- .../jet/lang/types/JetStandardLibrary.java | 60 ++++++------- .../lang/types/{Type.java => JetType.java} | 2 +- .../jet/lang/types/JetTypeChecker.java | 80 +++++++++--------- .../types/{TypeImpl.java => JetTypeImpl.java} | 12 +-- .../jet/lang/types/JetTypeInferrer.java | 84 +++++++++---------- ...LazySubstitutedPropertyDescriptorImpl.java | 4 +- .../LazySubstitutingFunctionDescriptor.java | 2 +- .../types/LazySubstitutingFunctionGroup.java | 2 +- .../jet/lang/types/NamespaceType.java | 2 +- .../jet/lang/types/PropertyDescriptor.java | 2 +- .../lang/types/PropertyDescriptorImpl.java | 6 +- .../jet/lang/types/TypeConstructor.java | 6 +- .../lang/types/TypeParameterDescriptor.java | 6 +- .../jet/lang/types/TypeProjection.java | 8 +- .../jet/lang/types/TypeSubstitutor.java | 20 ++--- .../jetbrains/jet/lang/types/TypeUtils.java | 28 +++---- .../types/ValueParameterDescriptorImpl.java | 2 +- .../jetbrains/jet/resolve/DescriptorUtil.java | 4 +- .../jet/resolve/ExpectedResolveData.java | 4 +- .../jetbrains/jet/resolve/JetResolveTest.java | 8 +- .../jet/types/JetTypeCheckerTest.java | 34 ++++---- 50 files changed, 326 insertions(+), 333 deletions(-) rename idea/src/org/jetbrains/jet/lang/types/{Type.java => JetType.java} (88%) rename idea/src/org/jetbrains/jet/lang/types/{TypeImpl.java => JetTypeImpl.java} (88%) diff --git a/idea/src/org/jetbrains/jet/codegen/FunctionCodegen.java b/idea/src/org/jetbrains/jet/codegen/FunctionCodegen.java index e8e48901537..0dcb3498795 100644 --- a/idea/src/org/jetbrains/jet/codegen/FunctionCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/FunctionCodegen.java @@ -2,10 +2,7 @@ package org.jetbrains.jet.codegen; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; -import org.jetbrains.jet.lang.types.FunctionDescriptor; -import org.jetbrains.jet.lang.types.JetStandardClasses; -import org.jetbrains.jet.lang.types.JetStandardLibrary; -import org.jetbrains.jet.lang.types.ValueParameterDescriptor; +import org.jetbrains.jet.lang.types.*; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; @@ -38,7 +35,7 @@ public class FunctionCodegen { Type returnType; if (returnTypeRef == null) { final FunctionDescriptor functionDescriptor = bindingContext.getFunctionDescriptor(f); - final org.jetbrains.jet.lang.types.Type type = functionDescriptor.getUnsubstitutedReturnType(); + final JetType type = functionDescriptor.getUnsubstitutedReturnType(); if (type.equals(JetStandardClasses.getUnitType())) { returnType = Type.VOID_TYPE; } @@ -73,7 +70,7 @@ public class FunctionCodegen { private void generateReturn(MethodVisitor mv, JetExpression bodyExpression) { if (!endsWithReturn(bodyExpression)) { - final org.jetbrains.jet.lang.types.Type expressionType = bindingContext.getExpressionType(bodyExpression); + final JetType expressionType = bindingContext.getExpressionType(bodyExpression); if (expressionType.equals(JetStandardClasses.getUnitType())) { mv.visitInsn(Opcodes.RETURN); } diff --git a/idea/src/org/jetbrains/jet/lang/ErrorHandler.java b/idea/src/org/jetbrains/jet/lang/ErrorHandler.java index f17e7147046..5b9041b3ae6 100644 --- a/idea/src/org/jetbrains/jet/lang/ErrorHandler.java +++ b/idea/src/org/jetbrains/jet/lang/ErrorHandler.java @@ -3,7 +3,7 @@ package org.jetbrains.jet.lang; import com.intellij.lang.ASTNode; import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetReferenceExpression; -import org.jetbrains.jet.lang.types.Type; +import org.jetbrains.jet.lang.types.JetType; /** * @author abreslav @@ -22,7 +22,7 @@ public class ErrorHandler { } @Override - public void typeMismatch(JetExpression expression, Type expectedType, Type actualType) { + public void typeMismatch(JetExpression expression, JetType expectedType, JetType actualType) { throw new IllegalStateException("Type mismatch: inferred type is " + actualType + " but " + expectedType + " was expected"); } }; @@ -33,6 +33,6 @@ public class ErrorHandler { public void structuralError(ASTNode node, String errorMessage) { } - public void typeMismatch(JetExpression expression, Type expectedType, Type actualType) { + public void typeMismatch(JetExpression expression, JetType expectedType, JetType actualType) { } } diff --git a/idea/src/org/jetbrains/jet/lang/annotations/JetPsiChecker.java b/idea/src/org/jetbrains/jet/lang/annotations/JetPsiChecker.java index ee892f5b2e7..e57f0bd43fd 100644 --- a/idea/src/org/jetbrains/jet/lang/annotations/JetPsiChecker.java +++ b/idea/src/org/jetbrains/jet/lang/annotations/JetPsiChecker.java @@ -15,7 +15,7 @@ import org.jetbrains.jet.lang.ErrorHandler; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.AnalyzingUtils; import org.jetbrains.jet.lang.resolve.BindingContext; -import org.jetbrains.jet.lang.types.Type; +import org.jetbrains.jet.lang.types.JetType; /** * @author abreslav @@ -49,7 +49,7 @@ public class JetPsiChecker implements Annotator { } @Override - public void typeMismatch(JetExpression expression, Type expectedType, Type actualType) { + public void typeMismatch(JetExpression expression, JetType expectedType, JetType actualType) { holder.createErrorAnnotation(expression, "Type mismatch: inferred type is " + actualType + " but " + expectedType + " was expected"); } }); @@ -58,7 +58,7 @@ public class JetPsiChecker implements Annotator { public void visitClass(JetClass klass) { for (JetDelegationSpecifier specifier : klass.getDelegationSpecifiers()) { JetTypeReference typeReference = specifier.getTypeReference(); - Type type = bindingContext.resolveTypeReference(typeReference); + JetType type = bindingContext.resolveTypeReference(typeReference); holder.createWeakWarningAnnotation(typeReference, type.toString()); } } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/BindingContext.java b/idea/src/org/jetbrains/jet/lang/resolve/BindingContext.java index e9e95a0ace0..9e227e372ed 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/BindingContext.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/BindingContext.java @@ -16,13 +16,13 @@ public interface BindingContext { DeclarationDescriptor getDeclarationDescriptor(JetDeclaration declaration); - Type getExpressionType(JetExpression expression); + JetType getExpressionType(JetExpression expression); JetScope getTopLevelScope(); DeclarationDescriptor resolveReferenceExpression(JetReferenceExpression referenceExpression); - Type resolveTypeReference(JetTypeReference typeReference); + JetType resolveTypeReference(JetTypeReference typeReference); PsiElement resolveToDeclarationPsiElement(JetReferenceExpression referenceExpression); PsiElement getDeclarationPsiElement(DeclarationDescriptor descriptor); } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java b/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java index c65c6259511..c481c2ba635 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java @@ -12,9 +12,9 @@ import java.util.Map; * @author abreslav */ public class BindingTraceContext extends BindingTrace implements BindingContext { - private final Map expressionTypes = new HashMap(); + private final Map expressionTypes = new HashMap(); private final Map resolutionResults = new HashMap(); - private final Map types = new HashMap(); + private final Map types = new HashMap(); private final Map descriptorToDeclarations = new HashMap(); private final Map declarationsToDescriptors = new HashMap(); private JetScope toplevelScope; @@ -22,7 +22,7 @@ public class BindingTraceContext extends BindingTrace implements BindingContext //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @Override - public void recordExpressionType(@NotNull JetExpression expression, @NotNull Type type) { + public void recordExpressionType(@NotNull JetExpression expression, @NotNull JetType type) { expressionTypes.put(expression, type); } @@ -32,7 +32,7 @@ public class BindingTraceContext extends BindingTrace implements BindingContext } @Override - public void recordTypeResolution(@NotNull JetTypeReference typeReference, @NotNull Type type) { + public void recordTypeResolution(@NotNull JetTypeReference typeReference, @NotNull JetType type) { types.put(typeReference, type); } @@ -79,12 +79,12 @@ public class BindingTraceContext extends BindingTrace implements BindingContext } @Override - public Type resolveTypeReference(JetTypeReference typeReference) { + public JetType resolveTypeReference(JetTypeReference typeReference) { return types.get(typeReference); } @Override - public Type getExpressionType(JetExpression expression) { + public JetType getExpressionType(JetExpression expression) { return expressionTypes.get(expression); } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java b/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java index 8bd3924cd37..39c51898779 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java @@ -38,7 +38,7 @@ public class ClassDescriptorResolver { List delegationSpecifiers = classElement.getDelegationSpecifiers(); // TODO : assuming that the hierarchy is acyclic - Collection superclasses = delegationSpecifiers.isEmpty() + Collection superclasses = delegationSpecifiers.isEmpty() ? Collections.singleton(JetStandardClasses.getAnyType()) : resolveTypes(parameterScope, delegationSpecifiers); boolean open = classElement.hasModifier(JetTokens.OPEN_KEYWORD); @@ -63,7 +63,7 @@ public class ClassDescriptorResolver { List delegationSpecifiers = classElement.getDelegationSpecifiers(); // TODO : assuming that the hierarchy is acyclic - Collection superclasses = delegationSpecifiers.isEmpty() + Collection superclasses = delegationSpecifiers.isEmpty() ? Collections.singleton(JetStandardClasses.getAnyType()) : resolveTypes(parameterScope, delegationSpecifiers); boolean open = classElement.hasModifier(JetTokens.OPEN_KEYWORD); @@ -86,7 +86,7 @@ public class ClassDescriptorResolver { List typeParameters, final JetScope outerScope, final JetScope typeParameterScope, - final Collection supertypes) { + final Collection supertypes) { final WritableScope memberDeclarations = new WritableScope(typeParameterScope, classDescriptor); @@ -136,7 +136,7 @@ public class ClassDescriptorResolver { List typeParameterDescriptors = resolveTypeParameters(functionDescriptor, parameterScope, function.getTypeParameters()); List valueParameterDescriptors = resolveValueParameters(functionDescriptor, parameterScope, function.getValueParameters()); - Type returnType; + JetType returnType; JetTypeReference returnTypeRef = function.getReturnTypeRef(); JetExpression bodyExpression = function.getBodyExpression(); if (returnTypeRef != null) { @@ -170,7 +170,7 @@ public class ClassDescriptorResolver { JetParameter valueParameter = valueParameters.get(i); JetTypeReference typeReference = valueParameter.getTypeReference(); - Type type; + JetType type; if (typeReference == null) { semanticServices.getErrorHandler().structuralError(valueParameter.getNode(), "A type annotation is required on a value parameter " + valueParameter.getName()); type = ErrorType.createErrorType("Type annotation was missing"); @@ -212,7 +212,7 @@ public class ClassDescriptorResolver { typeParameter.getVariance(), typeParameter.getName(), extendsBound == null - ? Collections.singleton(JetStandardClasses.getAnyType()) + ? Collections.singleton(JetStandardClasses.getAnyType()) : Collections.singleton(typeResolver.resolveType(extensibleScope, extendsBound)) ); extensibleScope.addTypeParameterDescriptor(typeParameterDescriptor); @@ -220,18 +220,18 @@ public class ClassDescriptorResolver { return typeParameterDescriptor; } - public Collection resolveTypes(WritableScope extensibleScope, List delegationSpecifiers) { + public Collection resolveTypes(WritableScope extensibleScope, List delegationSpecifiers) { if (delegationSpecifiers.isEmpty()) { return Collections.emptyList(); } - Collection result = new ArrayList(); + Collection result = new ArrayList(); for (JetDelegationSpecifier delegationSpecifier : delegationSpecifiers) { result.add(resolveType(extensibleScope, delegationSpecifier)); } return result; } - private Type resolveType(JetScope scope, JetDelegationSpecifier delegationSpecifier) { + private JetType resolveType(JetScope scope, JetDelegationSpecifier delegationSpecifier) { JetTypeReference typeReference = delegationSpecifier.getTypeReference(); // TODO : make it not null return typeResolver.resolveType(scope, typeReference); } @@ -249,7 +249,7 @@ public class ClassDescriptorResolver { // TODO : receiver? JetTypeReference propertyTypeRef = property.getPropertyTypeRef(); - Type type; + JetType type; if (propertyTypeRef == null) { JetExpression initializer = property.getInitializer(); if (initializer == null) { diff --git a/idea/src/org/jetbrains/jet/lang/resolve/JetScope.java b/idea/src/org/jetbrains/jet/lang/resolve/JetScope.java index 003a88afa45..6a4d46853dd 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/JetScope.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/JetScope.java @@ -32,7 +32,7 @@ public interface JetScope { TypeParameterDescriptor getTypeParameter(@NotNull String name); @NotNull - Type getThisType(); + JetType getThisType(); @NotNull FunctionGroup getFunctionGroup(@NotNull String name); diff --git a/idea/src/org/jetbrains/jet/lang/resolve/JetScopeAdapter.java b/idea/src/org/jetbrains/jet/lang/resolve/JetScopeAdapter.java index dea56873dce..a15ba19313b 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/JetScopeAdapter.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/JetScopeAdapter.java @@ -15,7 +15,7 @@ public class JetScopeAdapter implements JetScope { @NotNull @Override - public Type getThisType() { + public JetType getThisType() { return scope.getThisType(); } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/JetScopeImpl.java b/idea/src/org/jetbrains/jet/lang/resolve/JetScopeImpl.java index 98777dc0ea5..9da0a9778fb 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/JetScopeImpl.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/JetScopeImpl.java @@ -34,7 +34,7 @@ public abstract class JetScopeImpl implements JetScope { @NotNull @Override - public Type getThisType() { + public JetType getThisType() { return JetStandardClasses.getNothingType(); } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/OverloadDomain.java b/idea/src/org/jetbrains/jet/lang/resolve/OverloadDomain.java index a76abeaa51e..eaf1a7513c9 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/OverloadDomain.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/OverloadDomain.java @@ -3,7 +3,7 @@ package org.jetbrains.jet.lang.resolve; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.types.FunctionDescriptor; -import org.jetbrains.jet.lang.types.Type; +import org.jetbrains.jet.lang.types.JetType; import java.util.List; import java.util.Map; @@ -15,13 +15,13 @@ public interface OverloadDomain { OverloadDomain EMPTY = new OverloadDomain() { @Nullable @Override - public FunctionDescriptor getFunctionDescriptorForNamedArguments(@NotNull List typeArguments, @NotNull Map valueArgumentTypes, @Nullable Type functionLiteralArgumentType) { + public FunctionDescriptor getFunctionDescriptorForNamedArguments(@NotNull List typeArguments, @NotNull Map valueArgumentTypes, @Nullable JetType functionLiteralArgumentType) { return null; } @Nullable @Override - public FunctionDescriptor getFunctionDescriptorForPositionedArguments(@NotNull List typeArguments, @NotNull List positionedValueArgumentTypes) { + public FunctionDescriptor getFunctionDescriptorForPositionedArguments(@NotNull List typeArguments, @NotNull List positionedValueArgumentTypes) { return null; } }; @@ -34,9 +34,9 @@ public interface OverloadDomain { */ @Nullable FunctionDescriptor getFunctionDescriptorForNamedArguments( - @NotNull List typeArguments, - @NotNull Map valueArgumentTypes, - @Nullable Type functionLiteralArgumentType); + @NotNull List typeArguments, + @NotNull Map valueArgumentTypes, + @Nullable JetType functionLiteralArgumentType); /** * @param typeArguments @@ -45,6 +45,6 @@ public interface OverloadDomain { */ @Nullable FunctionDescriptor getFunctionDescriptorForPositionedArguments( - @NotNull List typeArguments, - @NotNull List positionedValueArgumentTypes); + @NotNull List typeArguments, + @NotNull List positionedValueArgumentTypes); } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/OverloadResolver.java b/idea/src/org/jetbrains/jet/lang/resolve/OverloadResolver.java index 4e7a55bdfa5..0e4bf0886fe 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/OverloadResolver.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/OverloadResolver.java @@ -18,7 +18,7 @@ public class OverloadResolver { } @NotNull - public OverloadDomain getOverloadDomain(Type receiverType, @NotNull JetScope outerScope, @NotNull String name) { + public OverloadDomain getOverloadDomain(JetType receiverType, @NotNull JetScope outerScope, @NotNull String name) { // TODO : extension lookup JetScope scope = receiverType == null ? outerScope : receiverType.getMemberScope(); @@ -30,7 +30,7 @@ public class OverloadResolver { return new OverloadDomain() { @Override - public FunctionDescriptor getFunctionDescriptorForPositionedArguments(@NotNull final List typeArguments, @NotNull List positionedValueArgumentTypes) { + public FunctionDescriptor getFunctionDescriptorForPositionedArguments(@NotNull final List typeArguments, @NotNull List positionedValueArgumentTypes) { Collection possiblyApplicableFunctions = functionGroup.getPossiblyApplicableFunctions(typeArguments, positionedValueArgumentTypes); if (possiblyApplicableFunctions.isEmpty()) { return null; @@ -50,8 +50,8 @@ public class OverloadResolver { // possibly, a single value passed to a vararg // possibly an array/list/etc passed as a whole vararg for (int i = 0, positionedValueArgumentTypesSize = positionedValueArgumentTypes.size(); i < positionedValueArgumentTypesSize; i++) { - Type argumentType = positionedValueArgumentTypes.get(i); - Type parameterType = parameters.get(i).getType(); + JetType argumentType = positionedValueArgumentTypes.get(i); + JetType parameterType = parameters.get(i).getType(); // TODO : handle vararg cases here if (!typeChecker.isConvertibleTo(argumentType, parameterType)) { continue descLoop; @@ -61,15 +61,15 @@ public class OverloadResolver { // vararg int nonVarargs = parameters.size() - 1; for (int i = 0; i < nonVarargs; i++) { - Type argumentType = positionedValueArgumentTypes.get(i); - Type parameterType = parameters.get(i).getType(); + JetType argumentType = positionedValueArgumentTypes.get(i); + JetType parameterType = parameters.get(i).getType(); if (!typeChecker.isConvertibleTo(argumentType, parameterType)) { continue descLoop; } } - Type varArgType = parameters.get(nonVarargs).getType(); + JetType varArgType = parameters.get(nonVarargs).getType(); for (int i = nonVarargs, args = positionedValueArgumentTypes.size(); i < args; i++) { - Type argumentType = positionedValueArgumentTypes.get(i); + JetType argumentType = positionedValueArgumentTypes.get(i); if (!typeChecker.isConvertibleTo(argumentType, varArgType)) { continue descLoop; } @@ -105,7 +105,7 @@ public class OverloadResolver { } @Override - public FunctionDescriptor getFunctionDescriptorForNamedArguments(@NotNull List typeArguments, @NotNull Map valueArgumentTypes, @Nullable Type functionLiteralArgumentType) { + public FunctionDescriptor getFunctionDescriptorForNamedArguments(@NotNull List typeArguments, @NotNull Map valueArgumentTypes, @Nullable JetType functionLiteralArgumentType) { throw new UnsupportedOperationException(); // TODO } }; @@ -118,8 +118,8 @@ public class OverloadResolver { int fSize = fParams.size(); if (fSize != gParams.size()) return false; for (int i = 0; i < fSize; i++) { - Type fParamType = fParams.get(i).getType(); - Type gParamType = gParams.get(i).getType(); + JetType fParamType = fParams.get(i).getType(); + JetType gParamType = gParams.get(i).getType(); // TODO : maybe isSubtypeOf is sufficient? if (!typeChecker.isConvertibleTo(fParamType, gParamType)) { diff --git a/idea/src/org/jetbrains/jet/lang/resolve/ScopeWithReceiver.java b/idea/src/org/jetbrains/jet/lang/resolve/ScopeWithReceiver.java index a182213a354..d929f717186 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/ScopeWithReceiver.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/ScopeWithReceiver.java @@ -11,7 +11,7 @@ public class ScopeWithReceiver extends JetScopeImpl { private final JetScope receiverTypeScope; private final JetScope outerScope; - public ScopeWithReceiver(JetScope outerScope, Type receiverType) { + public ScopeWithReceiver(JetScope outerScope, JetType receiverType) { this.outerScope = outerScope; this.receiverTypeScope = receiverType.getMemberScope(); } @@ -44,7 +44,7 @@ public class ScopeWithReceiver extends JetScopeImpl { @NotNull @Override - public Type getThisType() { + public JetType getThisType() { return receiverTypeScope.getThisType(); } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/SubstitutingScope.java b/idea/src/org/jetbrains/jet/lang/resolve/SubstitutingScope.java index b2e6972a175..39cf3b549d6 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/SubstitutingScope.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/SubstitutingScope.java @@ -53,7 +53,7 @@ public class SubstitutingScope implements JetScope { @NotNull @Override - public Type getThisType() { + public JetType getThisType() { throw new UnsupportedOperationException(); // TODO } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java b/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java index 1ae9765c428..9d39dbae2ff 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java @@ -78,7 +78,7 @@ public class TopDownAnalyzer { } if (importDirective.isAllUnder()) { JetExpression importedReference = importDirective.getImportedReference(); - Type type = semanticServices.getTypeInferrer(trace).getType(namespaceScope, importedReference, false); + JetType type = semanticServices.getTypeInferrer(trace).getType(namespaceScope, importedReference, false); if (type != null) { namespaceScope.importScope(type.getMemberScope()); } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/TypeResolver.java b/idea/src/org/jetbrains/jet/lang/resolve/TypeResolver.java index 5e68d7eed8a..9a21617c7b4 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/TypeResolver.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/TypeResolver.java @@ -25,18 +25,18 @@ public class TypeResolver { } @NotNull - public Type resolveType(@NotNull final JetScope scope, @NotNull final JetTypeReference typeReference) { + public JetType resolveType(@NotNull final JetScope scope, @NotNull final JetTypeReference typeReference) { final List attributes = AttributeResolver.INSTANCE.resolveAttributes(typeReference.getAttributes()); JetTypeElement typeElement = typeReference.getTypeElement(); - Type type = resolveTypeElement(scope, attributes, typeElement, false); + JetType type = resolveTypeElement(scope, attributes, typeElement, false); trace.recordTypeResolution(typeReference, type); return type; } @NotNull - private Type resolveTypeElement(final JetScope scope, final List attributes, JetTypeElement typeElement, final boolean nullable) { - final Type[] result = new Type[1]; + private JetType resolveTypeElement(final JetScope scope, final List attributes, JetTypeElement typeElement, final boolean nullable) { + final JetType[] result = new JetType[1]; if (typeElement != null) { typeElement.accept(new JetVisitor() { @Override @@ -46,7 +46,7 @@ public class TypeResolver { trace.recordReferenceResolution(type.getReferenceExpression(), classDescriptor); TypeConstructor typeConstructor = classDescriptor.getTypeConstructor(); List arguments = resolveTypeProjections(scope, typeConstructor, type.getTypeArguments()); - result[0] = new TypeImpl( + result[0] = new JetTypeImpl( attributes, typeConstructor, nullable, @@ -58,7 +58,7 @@ public class TypeResolver { TypeParameterDescriptor typeParameterDescriptor = scope.getTypeParameter(type.getReferencedName()); if (typeParameterDescriptor != null) { trace.recordReferenceResolution(type.getReferenceExpression(), typeParameterDescriptor); - result[0] = new TypeImpl( + result[0] = new JetTypeImpl( attributes, typeParameterDescriptor.getTypeConstructor(), nullable || hasNullableBound(typeParameterDescriptor), @@ -89,14 +89,14 @@ public class TypeResolver { @Override public void visitFunctionType(JetFunctionType type) { JetTypeReference receiverTypeRef = type.getReceiverTypeRef(); - Type receiverType = receiverTypeRef == null ? null : resolveType(scope, receiverTypeRef); + JetType receiverType = receiverTypeRef == null ? null : resolveType(scope, receiverTypeRef); - List parameterTypes = new ArrayList(); + List parameterTypes = new ArrayList(); for (JetParameter parameter : type.getParameters()) { parameterTypes.add(resolveType(scope, parameter.getTypeReference())); } - Type returnType = resolveType(scope, type.getReturnTypeRef()); + JetType returnType = resolveType(scope, type.getReturnTypeRef()); result[0] = JetStandardClasses.getFunctionType(attributes, receiverType, parameterTypes, returnType); } @@ -114,7 +114,7 @@ public class TypeResolver { } private boolean hasNullableBound(TypeParameterDescriptor typeParameterDescriptor) { - for (Type bound : typeParameterDescriptor.getUpperBounds()) { + for (JetType bound : typeParameterDescriptor.getUpperBounds()) { if (bound.isNullable()) { return true; } @@ -122,8 +122,8 @@ public class TypeResolver { return false; } - private List resolveTypes(JetScope scope, List argumentElements) { - final List arguments = new ArrayList(); + private List resolveTypes(JetScope scope, List argumentElements) { + final List arguments = new ArrayList(); for (JetTypeReference argumentElement : argumentElements) { arguments.add(resolveType(scope, argumentElement)); } @@ -137,9 +137,9 @@ public class TypeResolver { JetTypeProjection argumentElement = argumentElements.get(i); JetProjectionKind projectionKind = argumentElement.getProjectionKind(); - Type type; + JetType type; if (projectionKind == JetProjectionKind.STAR) { - Set upperBounds = constructor.getParameters().get(i).getUpperBounds(); + Set upperBounds = constructor.getParameters().get(i).getUpperBounds(); arguments.add(new TypeProjection(Variance.OUT_VARIANCE, TypeUtils.intersect(semanticServices.getTypeChecker(), upperBounds))); } else { diff --git a/idea/src/org/jetbrains/jet/lang/resolve/WritableFunctionGroup.java b/idea/src/org/jetbrains/jet/lang/resolve/WritableFunctionGroup.java index ba1bd87d6ad..6406a3caec9 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/WritableFunctionGroup.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/WritableFunctionGroup.java @@ -44,7 +44,7 @@ public class WritableFunctionGroup implements FunctionGroup { @NotNull @Override - public Collection getPossiblyApplicableFunctions(@NotNull List typeArguments, @NotNull List positionedValueArgumentTypes) { + public Collection getPossiblyApplicableFunctions(@NotNull List typeArguments, @NotNull List positionedValueArgumentTypes) { int typeArgCount = typeArguments.size(); int valueArgCount = positionedValueArgumentTypes.size(); Collection result = new ArrayList(); diff --git a/idea/src/org/jetbrains/jet/lang/resolve/WritableScope.java b/idea/src/org/jetbrains/jet/lang/resolve/WritableScope.java index cac4153894c..24ca04d7c2f 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/WritableScope.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/WritableScope.java @@ -24,7 +24,7 @@ public class WritableScope extends JetScopeAdapter { @Nullable private Map namespaceDescriptors; @Nullable - private Type thisType; + private JetType thisType; @Nullable private List imports; @@ -194,7 +194,7 @@ public class WritableScope extends JetScopeAdapter { @NotNull @Override - public Type getThisType() { + public JetType getThisType() { if (thisType == null) { return super.getThisType(); } @@ -243,7 +243,7 @@ public class WritableScope extends JetScopeAdapter { return super.getExtension(name); // TODO } - public void setThisType(Type thisType) { + public void setThisType(JetType thisType) { if (this.thisType != null) { throw new UnsupportedOperationException("Receiver redeclared"); } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java b/idea/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java index 646514c330a..d0f6551a337 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java @@ -99,7 +99,7 @@ public class JavaClassMembersScope implements JetScope { @NotNull @Override - public Type getThisType() { + public JetType getThisType() { return null; } } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java b/idea/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java index 55e244c75d9..7f68fd975b2 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java @@ -77,17 +77,17 @@ public class JavaDescriptorResolver { return classDescriptor; } - private Collection getSupertypes(PsiClass psiClass) { - List result = new ArrayList(); + private Collection getSupertypes(PsiClass psiClass) { + List result = new ArrayList(); result.add(JetStandardClasses.getAnyType()); transformSupertypeList(result, psiClass.getExtendsListTypes()); transformSupertypeList(result, psiClass.getImplementsListTypes()); return result; } - private void transformSupertypeList(List result, PsiClassType[] extendsListTypes) { + private void transformSupertypeList(List result, PsiClassType[] extendsListTypes) { for (PsiClassType type : extendsListTypes) { - Type transform = semanticServices.getTypeTransformer().transform(type); + JetType transform = semanticServices.getTypeTransformer().transform(type); result.add(TypeUtils.makeNotNullable(transform)); } diff --git a/idea/src/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer.java b/idea/src/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer.java index 99fab06005e..b2b807fb9ea 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer.java @@ -16,7 +16,7 @@ public class JavaTypeTransformer { private final JavaDescriptorResolver resolver; private final JetStandardLibrary standardLibrary; - private Map primitiveTypesMap; + private Map primitiveTypesMap; public JavaTypeTransformer(JetStandardLibrary standardLibrary, JavaDescriptorResolver resolver) { this.resolver = resolver; @@ -24,10 +24,10 @@ public class JavaTypeTransformer { } @NotNull - public Type transform(PsiType javaType) { - return javaType.accept(new PsiTypeVisitor() { + public JetType transform(PsiType javaType) { + return javaType.accept(new PsiTypeVisitor() { @Override - public Type visitClassType(PsiClassType classType) { + public JetType visitClassType(PsiClassType classType) { PsiClass psiClass = classType.resolveGenerics().getElement(); if (psiClass == null) { return ErrorType.createErrorType("Unresolved java class: " + classType.getPresentableText()); @@ -40,7 +40,7 @@ public class JavaTypeTransformer { ClassDescriptor descriptor = resolver.resolveClass(psiClass); // TODO : arguments & raw types List arguments = Collections.emptyList(); // TODO - return new TypeImpl( + return new JetTypeImpl( Collections.emptyList(), descriptor.getTypeConstructor(), true, @@ -49,29 +49,29 @@ public class JavaTypeTransformer { } @Override - public Type visitPrimitiveType(PsiPrimitiveType primitiveType) { + public JetType visitPrimitiveType(PsiPrimitiveType primitiveType) { String canonicalText = primitiveType.getCanonicalText(); - Type type = getPrimitiveTypesMap().get(canonicalText); + JetType type = getPrimitiveTypesMap().get(canonicalText); assert type != null : canonicalText; return type; } @Override - public Type visitArrayType(PsiArrayType arrayType) { - Type type = transform(arrayType.getComponentType()); + public JetType visitArrayType(PsiArrayType arrayType) { + JetType type = transform(arrayType.getComponentType()); return TypeUtils.makeNullable(standardLibrary.getArrayType(type)); } @Override - public Type visitType(PsiType type) { + public JetType visitType(PsiType type) { throw new UnsupportedOperationException("Unsupported type: " + type.getPresentableText()); // TODO } }); } - public Map getPrimitiveTypesMap() { + public Map getPrimitiveTypesMap() { if (primitiveTypesMap == null) { - primitiveTypesMap = new HashMap(); + primitiveTypesMap = new HashMap(); primitiveTypesMap.put("byte", standardLibrary.getByteType()); primitiveTypesMap.put("short", standardLibrary.getShortType()); primitiveTypesMap.put("char", standardLibrary.getCharType()); diff --git a/idea/src/org/jetbrains/jet/lang/types/BindingTrace.java b/idea/src/org/jetbrains/jet/lang/types/BindingTrace.java index cfbd73b68f5..a9f2a73c4c7 100644 --- a/idea/src/org/jetbrains/jet/lang/types/BindingTrace.java +++ b/idea/src/org/jetbrains/jet/lang/types/BindingTrace.java @@ -11,7 +11,7 @@ import org.jetbrains.jet.lang.resolve.JetScope; public class BindingTrace { public static final BindingTrace DUMMY = new BindingTrace(); - public void recordExpressionType(@NotNull JetExpression expression, @NotNull Type type) { + public void recordExpressionType(@NotNull JetExpression expression, @NotNull JetType type) { } public void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor) { @@ -22,7 +22,7 @@ public class BindingTrace { } - public void recordTypeResolution(@NotNull JetTypeReference typeReference, @NotNull Type type) { + public void recordTypeResolution(@NotNull JetTypeReference typeReference, @NotNull JetType type) { } diff --git a/idea/src/org/jetbrains/jet/lang/types/ClassDescriptorImpl.java b/idea/src/org/jetbrains/jet/lang/types/ClassDescriptorImpl.java index bb567ff592d..ee13b809591 100644 --- a/idea/src/org/jetbrains/jet/lang/types/ClassDescriptorImpl.java +++ b/idea/src/org/jetbrains/jet/lang/types/ClassDescriptorImpl.java @@ -32,7 +32,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorImpl implements Cl // public final ClassDescriptorImpl initialize(boolean sealed, List typeParameters, - Collection superclasses, JetScope memberDeclarations) { + Collection superclasses, JetScope memberDeclarations) { this.typeConstructor = new TypeConstructor(getAttributes(), sealed, getName(), typeParameters, superclasses); this.memberDeclarations = memberDeclarations; return this; diff --git a/idea/src/org/jetbrains/jet/lang/types/DfsNodeHandler.java b/idea/src/org/jetbrains/jet/lang/types/DfsNodeHandler.java index 8b47b363ffb..581736fe4c9 100644 --- a/idea/src/org/jetbrains/jet/lang/types/DfsNodeHandler.java +++ b/idea/src/org/jetbrains/jet/lang/types/DfsNodeHandler.java @@ -5,11 +5,11 @@ package org.jetbrains.jet.lang.types; */ public class DfsNodeHandler { - public void beforeChildren(Type current) { + public void beforeChildren(JetType current) { } - public void afterChildren(Type current) { + public void afterChildren(JetType current) { } diff --git a/idea/src/org/jetbrains/jet/lang/types/ErrorType.java b/idea/src/org/jetbrains/jet/lang/types/ErrorType.java index df37c68408d..0fb7031f5cd 100644 --- a/idea/src/org/jetbrains/jet/lang/types/ErrorType.java +++ b/idea/src/org/jetbrains/jet/lang/types/ErrorType.java @@ -38,7 +38,7 @@ public class ErrorType { @NotNull @Override - public Type getThisType() { + public JetType getThisType() { throw new UnsupportedOperationException(); // TODO } @@ -58,23 +58,23 @@ public class ErrorType { private ErrorType() {} - public static Type createErrorType(String debugMessage) { + public static JetType createErrorType(String debugMessage) { return createErrorType(debugMessage, ERROR_SCOPE); } - private static Type createErrorType(String debugMessage, JetScope memberScope) { - return new ErrorTypeImpl(new TypeConstructor(Collections.emptyList(), false, "[ERROR : " + debugMessage + "]", Collections.emptyList(), Collections.emptyList()), memberScope); + private static JetType createErrorType(String debugMessage, JetScope memberScope) { + return new ErrorTypeImpl(new TypeConstructor(Collections.emptyList(), false, "[ERROR : " + debugMessage + "]", Collections.emptyList(), Collections.emptyList()), memberScope); } - public static Type createWrongVarianceErrorType(TypeProjection value) { + public static JetType createWrongVarianceErrorType(TypeProjection value) { return createErrorType(value + " is not allowed here]", value.getType().getMemberScope()); } - public static boolean isErrorType(Type type) { + public static boolean isErrorType(JetType type) { return type instanceof ErrorTypeImpl; } - private static class ErrorTypeImpl implements Type { + private static class ErrorTypeImpl implements JetType { private final TypeConstructor constructor; private final JetScope memberScope; diff --git a/idea/src/org/jetbrains/jet/lang/types/FunctionDescriptor.java b/idea/src/org/jetbrains/jet/lang/types/FunctionDescriptor.java index 2fa493408e5..ef004808936 100644 --- a/idea/src/org/jetbrains/jet/lang/types/FunctionDescriptor.java +++ b/idea/src/org/jetbrains/jet/lang/types/FunctionDescriptor.java @@ -15,7 +15,7 @@ public interface FunctionDescriptor extends DeclarationDescriptor { List getUnsubstitutedValueParameters(); @NotNull - Type getUnsubstitutedReturnType(); + JetType getUnsubstitutedReturnType(); @NotNull FunctionDescriptor getOriginal(); diff --git a/idea/src/org/jetbrains/jet/lang/types/FunctionDescriptorImpl.java b/idea/src/org/jetbrains/jet/lang/types/FunctionDescriptorImpl.java index 61fa2ac707f..cf503725432 100644 --- a/idea/src/org/jetbrains/jet/lang/types/FunctionDescriptorImpl.java +++ b/idea/src/org/jetbrains/jet/lang/types/FunctionDescriptorImpl.java @@ -13,7 +13,7 @@ public class FunctionDescriptorImpl extends DeclarationDescriptorImpl implements private List unsubstitutedValueParameters; - private Type unsubstitutedReturnType; + private JetType unsubstitutedReturnType; private final FunctionDescriptor original; public FunctionDescriptorImpl( @@ -35,7 +35,7 @@ public class FunctionDescriptorImpl extends DeclarationDescriptorImpl implements public final void initialize( @NotNull List typeParameters, @NotNull List unsubstitutedValueParameters, - @NotNull Type unsubstitutedReturnType) { + @NotNull JetType unsubstitutedReturnType) { this.typeParameters = typeParameters; this.unsubstitutedValueParameters = unsubstitutedValueParameters; this.unsubstitutedReturnType = unsubstitutedReturnType; @@ -55,7 +55,7 @@ public class FunctionDescriptorImpl extends DeclarationDescriptorImpl implements @Override @NotNull - public Type getUnsubstitutedReturnType() { + public JetType getUnsubstitutedReturnType() { return unsubstitutedReturnType; } diff --git a/idea/src/org/jetbrains/jet/lang/types/FunctionDescriptorUtil.java b/idea/src/org/jetbrains/jet/lang/types/FunctionDescriptorUtil.java index 4d19292029b..9838ec78223 100644 --- a/idea/src/org/jetbrains/jet/lang/types/FunctionDescriptorUtil.java +++ b/idea/src/org/jetbrains/jet/lang/types/FunctionDescriptorUtil.java @@ -38,7 +38,7 @@ public class FunctionDescriptorUtil { } @NotNull - public static List getSubstitutedValueParameters(FunctionDescriptor substitutedDescriptor, @NotNull FunctionDescriptor functionDescriptor, @NotNull List typeArguments) { + public static List getSubstitutedValueParameters(FunctionDescriptor substitutedDescriptor, @NotNull FunctionDescriptor functionDescriptor, @NotNull List typeArguments) { List result = new ArrayList(); Map context = createSubstitutionContext(functionDescriptor, typeArguments); List unsubstitutedValueParameters = functionDescriptor.getUnsubstitutedValueParameters(); @@ -58,7 +58,7 @@ public class FunctionDescriptorUtil { return result; } - private static Map createSubstitutionContext(@NotNull FunctionDescriptor functionDescriptor, List typeArguments) { + private static Map createSubstitutionContext(@NotNull FunctionDescriptor functionDescriptor, List typeArguments) { Map result = new HashMap(); int typeArgumentsSize = typeArguments.size(); @@ -66,19 +66,19 @@ public class FunctionDescriptorUtil { assert typeArgumentsSize == typeParameters.size(); for (int i = 0; i < typeArgumentsSize; i++) { TypeParameterDescriptor typeParameterDescriptor = typeParameters.get(i); - Type typeArgument = typeArguments.get(i); + JetType typeArgument = typeArguments.get(i); result.put(typeParameterDescriptor.getTypeConstructor(), new TypeProjection(typeArgument)); } return result; } @NotNull - public static Type getSubstitutedReturnType(@NotNull FunctionDescriptor functionDescriptor, @NotNull List typeArguments) { + public static JetType getSubstitutedReturnType(@NotNull FunctionDescriptor functionDescriptor, @NotNull List typeArguments) { return TypeSubstitutor.INSTANCE.substitute(createSubstitutionContext(functionDescriptor, typeArguments), functionDescriptor.getUnsubstitutedReturnType(), Variance.OUT_VARIANCE); } @NotNull - public static FunctionDescriptor substituteFunctionDescriptor(@NotNull List typeArguments, @NotNull FunctionDescriptor functionDescriptor) { + public static FunctionDescriptor substituteFunctionDescriptor(@NotNull List typeArguments, @NotNull FunctionDescriptor functionDescriptor) { if (functionDescriptor.getTypeParameters().isEmpty()) { return functionDescriptor; } diff --git a/idea/src/org/jetbrains/jet/lang/types/FunctionGroup.java b/idea/src/org/jetbrains/jet/lang/types/FunctionGroup.java index edb131d8364..e115c991fe2 100644 --- a/idea/src/org/jetbrains/jet/lang/types/FunctionGroup.java +++ b/idea/src/org/jetbrains/jet/lang/types/FunctionGroup.java @@ -18,7 +18,7 @@ public interface FunctionGroup extends Named { @NotNull @Override - public Collection getPossiblyApplicableFunctions(@NotNull List typeArguments, @NotNull List positionedValueArgumentTypes) { + public Collection getPossiblyApplicableFunctions(@NotNull List typeArguments, @NotNull List positionedValueArgumentTypes) { return Collections.emptySet(); } @@ -34,7 +34,7 @@ public interface FunctionGroup extends Named { String getName(); @NotNull - Collection getPossiblyApplicableFunctions(@NotNull List typeArguments, @NotNull List positionedValueArgumentTypes); + Collection getPossiblyApplicableFunctions(@NotNull List typeArguments, @NotNull List positionedValueArgumentTypes); boolean isEmpty(); } diff --git a/idea/src/org/jetbrains/jet/lang/types/JetStandardClasses.java b/idea/src/org/jetbrains/jet/lang/types/JetStandardClasses.java index 07572e9b467..d62838843ce 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetStandardClasses.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetStandardClasses.java @@ -27,14 +27,14 @@ public class JetStandardClasses { "Nothing").initialize( true, Collections.emptyList(), - new AbstractCollection() { + new AbstractCollection() { @Override public boolean contains(Object o) { - return o instanceof Type; + return o instanceof JetType; } @Override - public Iterator iterator() { + public Iterator iterator() { throw new UnsupportedOperationException(); } @@ -44,9 +44,9 @@ public class JetStandardClasses { } }, JetScope.EMPTY ); - private static final Type NOTHING_TYPE = new TypeImpl(getNothing()); + private static final JetType NOTHING_TYPE = new JetTypeImpl(getNothing()); - private static final Type NULLABLE_NOTHING_TYPE = new TypeImpl( + private static final JetType NULLABLE_NOTHING_TYPE = new JetTypeImpl( Collections.emptyList(), getNothing().getTypeConstructor(), true, @@ -61,12 +61,12 @@ public class JetStandardClasses { "Any").initialize( false, Collections.emptyList(), - Collections.emptySet(), + Collections.emptySet(), JetScope.EMPTY ); - private static final Type ANY_TYPE = new TypeImpl(ANY.getTypeConstructor(), JetScope.EMPTY); + private static final JetType ANY_TYPE = new JetTypeImpl(ANY.getTypeConstructor(), JetScope.EMPTY); - private static final Type NULLABLE_ANY_TYPE = TypeUtils.makeNullable(ANY_TYPE); + private static final JetType NULLABLE_ANY_TYPE = TypeUtils.makeNullable(ANY_TYPE); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -152,7 +152,7 @@ public class JetStandardClasses { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - private static final Type UNIT_TYPE = new TypeImpl(getTuple(0)); + private static final JetType UNIT_TYPE = new JetTypeImpl(getTuple(0)); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -198,11 +198,11 @@ public class JetStandardClasses { } @NotNull - public static Type getAnyType() { + public static JetType getAnyType() { return ANY_TYPE; } - public static Type getNullableAnyType() { + public static JetType getNullableAnyType() { return NULLABLE_ANY_TYPE; } @@ -226,57 +226,57 @@ public class JetStandardClasses { return RECEIVER_FUNCTION[parameterCount]; } - public static Type getUnitType() { + public static JetType getUnitType() { return UNIT_TYPE; } - public static Type getNothingType() { + public static JetType getNothingType() { return NOTHING_TYPE; } - public static Type getNullableNothingType() { + public static JetType getNullableNothingType() { return NULLABLE_NOTHING_TYPE; } - public static boolean isNothing(Type type) { + public static boolean isNothing(JetType type) { return type.getConstructor() == NOTHING_CLASS.getTypeConstructor(); } - public static Type getTupleType(List attributes, List arguments) { + public static JetType getTupleType(List attributes, List arguments) { if (attributes.isEmpty() && arguments.isEmpty()) { return getUnitType(); } - return new TypeImpl(attributes, getTuple(arguments.size()).getTypeConstructor(), false, toProjections(arguments), STUB); + return new JetTypeImpl(attributes, getTuple(arguments.size()).getTypeConstructor(), false, toProjections(arguments), STUB); } - public static Type getTupleType(List arguments) { + public static JetType getTupleType(List arguments) { return getTupleType(Collections.emptyList(), arguments); } - public static Type getTupleType(Type... arguments) { + public static JetType getTupleType(JetType... arguments) { return getTupleType(Collections.emptyList(), Arrays.asList(arguments)); } - public static Type getLabeledTupleType(List attributes, List arguments) { + public static JetType getLabeledTupleType(List attributes, List arguments) { // TODO return getTupleType(attributes, toTypes(arguments)); } - public static Type getLabeledTupleType(List arguments) { + public static JetType getLabeledTupleType(List arguments) { // TODO return getLabeledTupleType(Collections.emptyList(), arguments); } - private static List toProjections(List arguments) { + private static List toProjections(List arguments) { List result = new ArrayList(); - for (Type argument : arguments) { + for (JetType argument : arguments) { result.add(new TypeProjection(Variance.OUT_VARIANCE, argument)); } return result; } - private static List toTypes(List labeledEntries) { - List result = new ArrayList(); + private static List toTypes(List labeledEntries) { + List result = new ArrayList(); for (ValueParameterDescriptor entry : labeledEntries) { result.add(entry.getType()); } @@ -284,21 +284,21 @@ public class JetStandardClasses { } // TODO : labeled version? - public static Type getFunctionType(List attributes, @Nullable Type receiverType, @NotNull List parameterTypes, @NotNull Type returnType) { + public static JetType getFunctionType(List attributes, @Nullable JetType receiverType, @NotNull List parameterTypes, @NotNull JetType returnType) { List arguments = new ArrayList(); if (receiverType != null) { arguments.add(defaultProjection(receiverType)); } - for (Type parameterType : parameterTypes) { + for (JetType parameterType : parameterTypes) { arguments.add(defaultProjection(parameterType)); } arguments.add(defaultProjection(returnType)); int size = parameterTypes.size(); TypeConstructor constructor = receiverType == null ? FUNCTION[size].getTypeConstructor() : RECEIVER_FUNCTION[size].getTypeConstructor(); - return new TypeImpl(attributes, constructor, false, arguments, STUB); + return new JetTypeImpl(attributes, constructor, false, arguments, STUB); } - private static TypeProjection defaultProjection(Type returnType) { + private static TypeProjection defaultProjection(JetType returnType) { return new TypeProjection(Variance.INVARIANT, returnType); } } diff --git a/idea/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java b/idea/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java index 0c2d4bc928d..a5a732bea49 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java @@ -50,15 +50,15 @@ public class JetStandardLibrary { private final ClassDescriptor stringClass; private final ClassDescriptor arrayClass; - private final Type byteType; - private final Type charType; - private final Type shortType; - private final Type intType; - private final Type longType; - private final Type floatType; - private final Type doubleType; - private final Type booleanType; - private final Type stringType; + private final JetType byteType; + private final JetType charType; + private final JetType shortType; + private final JetType intType; + private final JetType longType; + private final JetType floatType; + private final JetType doubleType; + private final JetType booleanType; + private final JetType stringType; private JetStandardLibrary(@NotNull Project project) { // TODO : review @@ -87,15 +87,15 @@ public class JetStandardLibrary { this.stringClass = libraryScope.getClass("String"); this.arrayClass = libraryScope.getClass("Array"); - this.byteType = new TypeImpl(getByte()); - this.charType = new TypeImpl(getChar()); - this.shortType = new TypeImpl(getShort()); - this.intType = new TypeImpl(getInt()); - this.longType = new TypeImpl(getLong()); - this.floatType = new TypeImpl(getFloat()); - this.doubleType = new TypeImpl(getDouble()); - this.booleanType = new TypeImpl(getBoolean()); - this.stringType = new TypeImpl(getString()); + this.byteType = new JetTypeImpl(getByte()); + this.charType = new JetTypeImpl(getChar()); + this.shortType = new JetTypeImpl(getShort()); + this.intType = new JetTypeImpl(getInt()); + this.longType = new JetTypeImpl(getLong()); + this.floatType = new JetTypeImpl(getFloat()); + this.doubleType = new JetTypeImpl(getDouble()); + this.booleanType = new JetTypeImpl(getBoolean()); + this.stringType = new JetTypeImpl(getString()); } catch (IOException e) { throw new IllegalStateException(e); } @@ -156,60 +156,60 @@ public class JetStandardLibrary { } @NotNull - public Type getIntType() { + public JetType getIntType() { return intType; } @NotNull - public Type getLongType() { + public JetType getLongType() { return longType; } @NotNull - public Type getDoubleType() { + public JetType getDoubleType() { return doubleType; } @NotNull - public Type getFloatType() { + public JetType getFloatType() { return floatType; } @NotNull - public Type getCharType() { + public JetType getCharType() { return charType; } @NotNull - public Type getBooleanType() { + public JetType getBooleanType() { return booleanType; } @NotNull - public Type getStringType() { + public JetType getStringType() { return stringType; } @NotNull - public Type getByteType() { + public JetType getByteType() { return byteType; } @NotNull - public Type getShortType() { + public JetType getShortType() { return shortType; } @NotNull - public Type getArrayType(@NotNull Type argument) { + public JetType getArrayType(@NotNull JetType argument) { Variance variance = Variance.INVARIANT; return getArrayType(variance, argument); } @NotNull - public Type getArrayType(@NotNull Variance variance, @NotNull Type argument) { + public JetType getArrayType(@NotNull Variance variance, @NotNull JetType argument) { List types = Collections.singletonList(new TypeProjection(variance, argument)); - return new TypeImpl( + return new JetTypeImpl( Collections.emptyList(), getArray().getTypeConstructor(), false, diff --git a/idea/src/org/jetbrains/jet/lang/types/Type.java b/idea/src/org/jetbrains/jet/lang/types/JetType.java similarity index 88% rename from idea/src/org/jetbrains/jet/lang/types/Type.java rename to idea/src/org/jetbrains/jet/lang/types/JetType.java index c3139bac462..62aa4969fc5 100644 --- a/idea/src/org/jetbrains/jet/lang/types/Type.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetType.java @@ -8,7 +8,7 @@ import java.util.List; /** * @author abreslav */ -public interface Type extends Annotated { +public interface JetType extends Annotated { @NotNull TypeConstructor getConstructor(); @NotNull List getArguments(); boolean isNullable(); diff --git a/idea/src/org/jetbrains/jet/lang/types/JetTypeChecker.java b/idea/src/org/jetbrains/jet/lang/types/JetTypeChecker.java index fca21a33970..ce9865c2816 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetTypeChecker.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetTypeChecker.java @@ -63,12 +63,12 @@ public class JetTypeChecker { conversionMap.put(actual.getTypeConstructor(), new HashSet(Arrays.asList(constructors))); } - public Type commonSupertype(Collection types) { - Collection typeSet = new HashSet(types); + public JetType commonSupertype(Collection types) { + Collection typeSet = new HashSet(types); assert !typeSet.isEmpty(); boolean nullable = false; - for (Iterator iterator = typeSet.iterator(); iterator.hasNext();) { - Type type = iterator.next(); + for (Iterator iterator = typeSet.iterator(); iterator.hasNext();) { + JetType type = iterator.next(); if (JetStandardClasses.isNothing(type)) { iterator.remove(); } @@ -84,22 +84,22 @@ public class JetTypeChecker { return TypeUtils.makeNullableIfNeeded(typeSet.iterator().next(), nullable); } - Map> commonSupertypes = computeCommonRawSupertypes(typeSet); + Map> commonSupertypes = computeCommonRawSupertypes(typeSet); while (commonSupertypes.size() > 1) { - HashSet merge = new HashSet(); - for (Set supertypes : commonSupertypes.values()) { + HashSet merge = new HashSet(); + for (Set supertypes : commonSupertypes.values()) { merge.addAll(supertypes); } commonSupertypes = computeCommonRawSupertypes(merge); } assert !commonSupertypes.isEmpty(); - Map.Entry> entry = commonSupertypes.entrySet().iterator().next(); - Type result = computeSupertypeProjections(entry.getKey(), entry.getValue()); + Map.Entry> entry = commonSupertypes.entrySet().iterator().next(); + JetType result = computeSupertypeProjections(entry.getKey(), entry.getValue()); return TypeUtils.makeNullableIfNeeded(result, nullable); } - private Type computeSupertypeProjections(TypeConstructor constructor, Set types) { + private JetType computeSupertypeProjections(TypeConstructor constructor, Set types) { // we assume that all the given types are applications of the same type constructor assert !types.isEmpty(); @@ -113,19 +113,19 @@ public class JetTypeChecker { for (int i = 0, parametersSize = parameters.size(); i < parametersSize; i++) { TypeParameterDescriptor parameterDescriptor = parameters.get(i); Set typeProjections = new HashSet(); - for (Type type : types) { + for (JetType type : types) { typeProjections.add(type.getArguments().get(i)); } newProjections.add(computeSupertypeProjection(parameterDescriptor, typeProjections)); } boolean nullable = false; - for (Type type : types) { + for (JetType type : types) { nullable |= type.isNullable(); } // TODO : attributes? - return new TypeImpl(Collections.emptyList(), constructor, nullable, newProjections, JetStandardClasses.STUB); + return new JetTypeImpl(Collections.emptyList(), constructor, nullable, newProjections, JetStandardClasses.STUB); } private TypeProjection computeSupertypeProjection(TypeParameterDescriptor parameterDescriptor, Set typeProjections) { @@ -133,8 +133,8 @@ public class JetTypeChecker { return typeProjections.iterator().next(); } - Set ins = new HashSet(); - Set outs = new HashSet(); + Set ins = new HashSet(); + Set outs = new HashSet(); Variance variance = parameterDescriptor.getVariance(); switch (variance) { @@ -170,7 +170,7 @@ public class JetTypeChecker { if (ins != null) { Variance projectionKind = variance == Variance.IN_VARIANCE ? Variance.INVARIANT : Variance.IN_VARIANCE; - Type intersection = TypeUtils.intersect(this, ins); + JetType intersection = TypeUtils.intersect(this, ins); if (intersection == null) { return new TypeProjection(Variance.OUT_VARIANCE, commonSupertype(parameterDescriptor.getUpperBounds())); } @@ -184,33 +184,33 @@ public class JetTypeChecker { } } - private Map> computeCommonRawSupertypes(Collection types) { + private Map> computeCommonRawSupertypes(Collection types) { assert !types.isEmpty(); - final Map> constructorToAllInstances = new HashMap>(); + final Map> constructorToAllInstances = new HashMap>(); Set commonSuperclasses = null; List order = null; - for (Type type : types) { + for (JetType type : types) { Set visited = new HashSet(); order = dfs(type, visited, new DfsNodeHandler>() { public LinkedList list = new LinkedList(); @Override - public void beforeChildren(Type current) { + public void beforeChildren(JetType current) { TypeConstructor constructor = current.getConstructor(); - Set instances = constructorToAllInstances.get(constructor); + Set instances = constructorToAllInstances.get(constructor); if (instances == null) { - instances = new HashSet(); + instances = new HashSet(); constructorToAllInstances.put(constructor, instances); } instances.add(current); } @Override - public void afterChildren(Type current) { + public void afterChildren(JetType current) { list.addFirst(current.getConstructor()); } @@ -230,7 +230,7 @@ public class JetTypeChecker { assert order != null; Set notSource = new HashSet(); - Map> result = new HashMap>(); + Map> result = new HashMap>(); for (TypeConstructor superConstructor : order) { if (!commonSuperclasses.contains(superConstructor)) { continue; @@ -247,38 +247,38 @@ public class JetTypeChecker { private void markAll(TypeConstructor typeConstructor, Set markerSet) { markerSet.add(typeConstructor); - for (Type type : typeConstructor.getSupertypes()) { + for (JetType type : typeConstructor.getSupertypes()) { markAll(type.getConstructor(), markerSet); } } - private R dfs(Type current, Set visited, DfsNodeHandler handler) { + private R dfs(JetType current, Set visited, DfsNodeHandler handler) { doDfs(current, visited, handler); return handler.result(); } - private void doDfs(Type current, Set visited, DfsNodeHandler handler) { + private void doDfs(JetType current, Set visited, DfsNodeHandler handler) { if (!visited.add(current.getConstructor())) { return; } handler.beforeChildren(current); Map substitutionContext = TypeSubstitutor.INSTANCE.getSubstitutionContext(current); - for (Type supertype : current.getConstructor().getSupertypes()) { + for (JetType supertype : current.getConstructor().getSupertypes()) { TypeConstructor supertypeConstructor = supertype.getConstructor(); if (visited.contains(supertypeConstructor)) { continue; } - Type substitutedSupertype = TypeSubstitutor.INSTANCE.substitute(substitutionContext, supertype, Variance.INVARIANT); + JetType substitutedSupertype = TypeSubstitutor.INSTANCE.substitute(substitutionContext, supertype, Variance.INVARIANT); dfs(substitutedSupertype, visited, handler); } handler.afterChildren(current); } - public boolean isConvertibleTo(JetExpression expression, Type type) { + public boolean isConvertibleTo(JetExpression expression, JetType type) { throw new UnsupportedOperationException(); // TODO } - public boolean isConvertibleTo(Type actual, Type expected) { + public boolean isConvertibleTo(JetType actual, JetType expected) { if (isSubtypeOf(actual, expected)) return true; if (expected.getConstructor() == JetStandardClasses.getTuple(0).getTypeConstructor()) { return true; @@ -294,14 +294,14 @@ public class JetTypeChecker { return false; } - public boolean isSubtypeOf(@NotNull Type subtype, @NotNull Type supertype) { + public boolean isSubtypeOf(@NotNull JetType subtype, @NotNull JetType supertype) { if (!supertype.isNullable() && subtype.isNullable()) { return false; } if (JetStandardClasses.isNothing(subtype)) { return true; } - @Nullable Type closestSupertype = findCorrespondingSupertype(subtype, supertype); + @Nullable JetType closestSupertype = findCorrespondingSupertype(subtype, supertype); if (closestSupertype == null) { return false; } @@ -312,13 +312,13 @@ public class JetTypeChecker { // This method returns the supertype of the first parameter that has the same constructor // as the second parameter, applying the substitution of type arguments to it @Nullable - private Type findCorrespondingSupertype(Type subtype, Type supertype) { + private JetType findCorrespondingSupertype(JetType subtype, JetType supertype) { TypeConstructor constructor = subtype.getConstructor(); if (constructor.equals(supertype.getConstructor())) { return subtype; } - for (Type immediateSupertype : constructor.getSupertypes()) { - Type correspondingSupertype = findCorrespondingSupertype(immediateSupertype, supertype); + for (JetType immediateSupertype : constructor.getSupertypes()) { + JetType correspondingSupertype = findCorrespondingSupertype(immediateSupertype, supertype); if (correspondingSupertype != null) { return TypeSubstitutor.INSTANCE.substitute(subtype, correspondingSupertype, Variance.INVARIANT); } @@ -326,7 +326,7 @@ public class JetTypeChecker { return null; } - private boolean checkSubtypeForTheSameConstructor(Type subtype, Type supertype) { + private boolean checkSubtypeForTheSameConstructor(JetType subtype, JetType supertype) { TypeConstructor constructor = subtype.getConstructor(); assert constructor.equals(supertype.getConstructor()); @@ -338,13 +338,13 @@ public class JetTypeChecker { TypeProjection subArgument = subArguments.get(i); TypeProjection superArgument = superArguments.get(i); - Type subArgumentType = subArgument.getType(); - Type superArgumentType = superArgument.getType(); + JetType subArgumentType = subArgument.getType(); + JetType superArgumentType = superArgument.getType(); switch (parameter.getVariance()) { case INVARIANT: switch (superArgument.getProjectionKind()) { case INVARIANT: - if (!TypeImpl.equalTypes(subArgumentType, superArgumentType)) { + if (!JetTypeImpl.equalTypes(subArgumentType, superArgumentType)) { return false; } break; diff --git a/idea/src/org/jetbrains/jet/lang/types/TypeImpl.java b/idea/src/org/jetbrains/jet/lang/types/JetTypeImpl.java similarity index 88% rename from idea/src/org/jetbrains/jet/lang/types/TypeImpl.java rename to idea/src/org/jetbrains/jet/lang/types/JetTypeImpl.java index 11a5fc41133..3f519ef6fc0 100644 --- a/idea/src/org/jetbrains/jet/lang/types/TypeImpl.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetTypeImpl.java @@ -10,14 +10,14 @@ import java.util.List; /** * @author abreslav */ -public final class TypeImpl extends AnnotatedImpl implements Type { +public final class JetTypeImpl extends AnnotatedImpl implements JetType { private final TypeConstructor constructor; private final List arguments; private final boolean nullable; private JetScope memberScope; - public TypeImpl(List attributes, TypeConstructor constructor, boolean nullable, List arguments, JetScope memberScope) { + public JetTypeImpl(List attributes, TypeConstructor constructor, boolean nullable, List arguments, JetScope memberScope) { super(attributes); this.constructor = constructor; this.nullable = nullable; @@ -25,11 +25,11 @@ public final class TypeImpl extends AnnotatedImpl implements Type { this.memberScope = memberScope; } - public TypeImpl(TypeConstructor constructor, JetScope memberScope) { + public JetTypeImpl(TypeConstructor constructor, JetScope memberScope) { this(Collections.emptyList(), constructor, false, Collections.emptyList(), memberScope); } - public TypeImpl(@NotNull ClassDescriptor classDescriptor) { + public JetTypeImpl(@NotNull ClassDescriptor classDescriptor) { this(Collections.emptyList(), classDescriptor.getTypeConstructor(), false, @@ -82,7 +82,7 @@ public final class TypeImpl extends AnnotatedImpl implements Type { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - TypeImpl type = (TypeImpl) o; + JetTypeImpl type = (JetTypeImpl) o; // TODO return equalTypes(this, type); @@ -103,7 +103,7 @@ public final class TypeImpl extends AnnotatedImpl implements Type { } - public static boolean equalTypes(@NotNull Type type1, @NotNull Type type2) { + public static boolean equalTypes(@NotNull JetType type1, @NotNull JetType type2) { if (type1.isNullable() != type2.isNullable()) { return false; } diff --git a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java index 0516f0ee703..2efdb8b32b3 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java @@ -29,8 +29,8 @@ public class JetTypeInferrer { } @NotNull - public Type safeGetType(@NotNull final JetScope scope, @NotNull JetExpression expression, final boolean preferBlock) { - Type type = getType(scope, expression, preferBlock); + public JetType safeGetType(@NotNull final JetScope scope, @NotNull JetExpression expression, final boolean preferBlock) { + JetType type = getType(scope, expression, preferBlock); if (type != null) { return type; } @@ -38,8 +38,8 @@ public class JetTypeInferrer { } @Nullable - public Type getType(@NotNull final JetScope scope, @NotNull JetExpression expression, final boolean preferBlock) { - final Type[] result = new Type[1]; + public JetType getType(@NotNull final JetScope scope, @NotNull JetExpression expression, final boolean preferBlock) { + final JetType[] result = new JetType[1]; expression.accept(new JetVisitor() { @Override public void visitReferenceExpression(JetSimpleNameExpression expression) { @@ -74,7 +74,7 @@ public class JetTypeInferrer { JetTypeReference returnTypeRef = expression.getReturnTypeRef(); JetTypeReference receiverTypeRef = expression.getReceiverTypeRef(); - final Type receiverType; + final JetType receiverType; if (receiverTypeRef != null) { receiverType = typeResolver.resolveType(scope, receiverTypeRef); } else { @@ -83,7 +83,7 @@ public class JetTypeInferrer { List body = expression.getBody(); final Map parameterDescriptors = new HashMap(); - List parameterTypes = new ArrayList(); + List parameterTypes = new ArrayList(); for (JetParameter parameter : expression.getParameters()) { JetTypeReference typeReference = parameter.getTypeReference(); if (typeReference == null) { @@ -93,7 +93,7 @@ public class JetTypeInferrer { parameterDescriptors.put(parameter.getName(), propertyDescriptor); parameterTypes.add(propertyDescriptor.getType()); } - Type returnType; + JetType returnType; if (returnTypeRef != null) { returnType = typeResolver.resolveType(scope, returnTypeRef); } else { @@ -174,8 +174,8 @@ public class JetTypeInferrer { @Override public void visitBinaryWithTypeRHSExpression(JetBinaryExpressionWithTypeRHS expression) { if (expression.getOperationReference().getReferencedNameElementType() == JetTokens.COLON) { - Type actualType = getType(scope, expression.getLeft(), false); - Type expectedType = typeResolver.resolveType(scope, expression.getRight()); + JetType actualType = getType(scope, expression.getLeft(), false); + JetType expectedType = typeResolver.resolveType(scope, expression.getRight()); if (actualType != null && !semanticServices.getTypeChecker().isSubtypeOf(actualType, expectedType)) { // TODO semanticServices.getErrorHandler().typeMismatch(expression.getLeft(), expectedType, actualType); @@ -195,8 +195,8 @@ public class JetTypeInferrer { // TODO : type-check the branch result[0] = JetStandardClasses.getUnitType(); } else { - Type thenType = getType(scope, expression.getThen(), true); - Type elseType = getType(scope, elseBranch, true); + JetType thenType = getType(scope, expression.getThen(), true); + JetType elseType = getType(scope, elseBranch, true); result[0] = semanticServices.getTypeChecker().commonSupertype(Arrays.asList(thenType, elseType)); } } @@ -204,7 +204,7 @@ public class JetTypeInferrer { @Override public void visitWhenExpression(JetWhenExpression expression) { // TODO :change scope according to the bound value in the when header - List expressions = new ArrayList(); + List expressions = new ArrayList(); collectAllReturnTypes(expression, scope, expressions); result[0] = semanticServices.getTypeChecker().commonSupertype(expressions); } @@ -214,7 +214,7 @@ public class JetTypeInferrer { JetExpression tryBlock = expression.getTryBlock(); List catchClauses = expression.getCatchClauses(); JetFinallySection finallyBlock = expression.getFinallyBlock(); - List types = new ArrayList(); + List types = new ArrayList(); if (finallyBlock == null) { for (JetCatchClause catchClause : catchClauses) { // TODO: change scope here @@ -230,7 +230,7 @@ public class JetTypeInferrer { @Override public void visitTupleExpression(JetTupleExpression expression) { List entries = expression.getEntries(); - List types = new ArrayList(); + List types = new ArrayList(); for (JetExpression entry : entries) { types.add(getType(scope, entry, false)); } @@ -241,15 +241,15 @@ public class JetTypeInferrer { @Override public void visitThisExpression(JetThisExpression expression) { // TODO : qualified this, e.g. Foo.this - Type thisType = scope.getThisType(); + JetType thisType = scope.getThisType(); JetTypeReference superTypeQualifier = expression.getSuperTypeQualifier(); if (superTypeQualifier != null) { // This cast must be safe (assuming the PSI doesn't contain errors) JetUserType typeElement = (JetUserType) superTypeQualifier.getTypeElement(); ClassDescriptor superclass = typeResolver.resolveClass(scope, typeElement); - Collection supertypes = thisType.getConstructor().getSupertypes(); + Collection supertypes = thisType.getConstructor().getSupertypes(); Map substitutionContext = TypeSubstitutor.INSTANCE.getSubstitutionContext(thisType); - for (Type declaredSupertype : supertypes) { + for (JetType declaredSupertype : supertypes) { if (declaredSupertype.getConstructor().equals(superclass.getTypeConstructor())) { result[0] = TypeSubstitutor.INSTANCE.substitute(substitutionContext, declaredSupertype, Variance.INVARIANT); break; @@ -283,7 +283,7 @@ public class JetTypeInferrer { // TODO : functions JetExpression receiverExpression = expression.getReceiverExpression(); JetExpression selectorExpression = expression.getSelectorExpression(); - Type receiverType = getType(scope, receiverExpression, false); + JetType receiverType = getType(scope, receiverExpression, false); if (receiverType != null) { // TODO : review JetScope compositeScope = new ScopeWithReceiver(scope, receiverType); result[0] = getType(compositeScope, selectorExpression, false); @@ -322,7 +322,7 @@ public class JetTypeInferrer { // result[0] = overloadDomain.getFunctionDescriptorForNamedArguments(typeArguments, valueArguments, functionLiteralArgument); } else { - List types = new ArrayList(); + List types = new ArrayList(); for (JetTypeProjection projection : typeArguments) { // TODO : check that there's no projection types.add(typeResolver.resolveType(scope, projection.getTypeReference())); @@ -335,7 +335,7 @@ public class JetTypeInferrer { positionedValueArguments.addAll(functionLiteralArguments); - List valueArgumentTypes = new ArrayList(); + List valueArgumentTypes = new ArrayList(); for (JetExpression valueArgument : positionedValueArguments) { valueArgumentTypes.add(getType(scope, valueArgument, false)); } @@ -378,9 +378,9 @@ public class JetTypeInferrer { @Override public void visitArrayAccessExpression(JetArrayAccessExpression expression) { JetExpression arrayExpression = expression.getArrayExpression(); - Type receiverType = getType(scope, arrayExpression, false); + JetType receiverType = getType(scope, arrayExpression, false); List indexExpressions = expression.getIndexExpressions(); - List argumentTypes = getTypes(scope, indexExpressions); + List argumentTypes = getTypes(scope, indexExpressions); if (argumentTypes == null) return; FunctionDescriptor functionDescriptor = lookupFunction(scope, expression, "get", receiverType, argumentTypes); @@ -390,13 +390,13 @@ public class JetTypeInferrer { } private void resolveArrayAccessToLValue(JetArrayAccessExpression arrayAccessExpression, JetExpression rightHandSide, JetSimpleNameExpression operationSign) { - List argumentTypes = getTypes(scope, arrayAccessExpression.getIndexExpressions()); + List argumentTypes = getTypes(scope, arrayAccessExpression.getIndexExpressions()); if (argumentTypes == null) return; - Type rhsType = getType(scope, rightHandSide, false); + JetType rhsType = getType(scope, rightHandSide, false); if (rhsType == null) return; argumentTypes.add(rhsType); - Type receiverType = getType(scope, arrayAccessExpression.getArrayExpression(), false); + JetType receiverType = getType(scope, arrayAccessExpression.getArrayExpression(), false); if (receiverType == null) return; // TODO : nasty hack: effort is duplicated @@ -412,15 +412,15 @@ public class JetTypeInferrer { throw new IllegalArgumentException("Unsupported element: " + elem); } - private Type getTypeForBinaryCall(JetBinaryExpression expression, String name, JetScope scope) { + private JetType getTypeForBinaryCall(JetBinaryExpression expression, String name, JetScope scope) { JetSimpleNameExpression operationSign = expression.getOperationReference(); JetExpression left = expression.getLeft(); - Type leftType = getType(scope, left, false); + JetType leftType = getType(scope, left, false); JetExpression right = expression.getRight(); if (right == null) { return ErrorType.createErrorType("No right argument"); } - Type rightType = getType(scope, right, false); + JetType rightType = getType(scope, right, false); FunctionDescriptor functionDescriptor = lookupFunction(scope, operationSign, name, leftType, Collections.singletonList(rightType)); if (functionDescriptor != null) { return functionDescriptor.getUnsubstitutedReturnType(); @@ -443,17 +443,17 @@ public class JetTypeInferrer { } @Nullable - private FunctionDescriptor lookupFunction(JetScope scope, JetReferenceExpression reference, String name, Type receiverType, List argumentTypes) { + private FunctionDescriptor lookupFunction(JetScope scope, JetReferenceExpression reference, String name, JetType receiverType, List argumentTypes) { OverloadDomain overloadDomain = semanticServices.getOverloadResolver().getOverloadDomain(receiverType, scope, name); overloadDomain = wrapForTracing(overloadDomain, reference); - return overloadDomain.getFunctionDescriptorForPositionedArguments(Collections.emptyList(), argumentTypes); + return overloadDomain.getFunctionDescriptorForPositionedArguments(Collections.emptyList(), argumentTypes); } @Nullable - private List getTypes(JetScope scope, List indexExpressions) { - List argumentTypes = new ArrayList(); + private List getTypes(JetScope scope, List indexExpressions) { + List argumentTypes = new ArrayList(); for (JetExpression indexExpression : indexExpressions) { - Type type = getType(scope, indexExpression, false); + JetType type = getType(scope, indexExpression, false); if (type == null) { return null; } @@ -487,7 +487,7 @@ public class JetTypeInferrer { if (selectorExpression instanceof JetSimpleNameExpression) { JetSimpleNameExpression referenceExpression = (JetSimpleNameExpression) selectorExpression; - Type receiverType = getType(scope, expression.getReceiverExpression(), false); + JetType receiverType = getType(scope, expression.getReceiverExpression(), false); if (receiverType != null) { result[0] = semanticServices.getOverloadResolver().getOverloadDomain(receiverType, scope, referenceExpression.getReferencedName()); reference[0] = referenceExpression; @@ -522,7 +522,7 @@ public class JetTypeInferrer { if (overloadDomain == null) return OverloadDomain.EMPTY; return new OverloadDomain() { @Override - public FunctionDescriptor getFunctionDescriptorForNamedArguments(@NotNull List typeArguments, @NotNull Map valueArgumentTypes, @Nullable Type functionLiteralArgumentType) { + public FunctionDescriptor getFunctionDescriptorForNamedArguments(@NotNull List typeArguments, @NotNull Map valueArgumentTypes, @Nullable JetType functionLiteralArgumentType) { FunctionDescriptor descriptor = overloadDomain.getFunctionDescriptorForNamedArguments(typeArguments, valueArgumentTypes, functionLiteralArgumentType); if (descriptor != null) { trace.recordReferenceResolution(referenceExpression, descriptor); @@ -533,23 +533,19 @@ public class JetTypeInferrer { } @Override - public FunctionDescriptor getFunctionDescriptorForPositionedArguments(@NotNull List typeArguments, @NotNull List positionedValueArgumentTypes) { + public FunctionDescriptor getFunctionDescriptorForPositionedArguments(@NotNull List typeArguments, @NotNull List positionedValueArgumentTypes) { FunctionDescriptor descriptor = overloadDomain.getFunctionDescriptorForPositionedArguments(typeArguments, positionedValueArgumentTypes); if (descriptor != null) { - if (referenceExpression != null) { - trace.recordReferenceResolution(referenceExpression, descriptor); - } + trace.recordReferenceResolution(referenceExpression, descriptor); } else { - if (referenceExpression != null) { - semanticServices.getErrorHandler().unresolvedReference(referenceExpression); - } + semanticServices.getErrorHandler().unresolvedReference(referenceExpression); } return descriptor; } }; } - private Type getBlockReturnedType(@NotNull JetScope outerScope, List block) { + private JetType getBlockReturnedType(@NotNull JetScope outerScope, List block) { if (block.isEmpty()) { return JetStandardClasses.getUnitType(); } else { @@ -580,7 +576,7 @@ public class JetTypeInferrer { } } - private void collectAllReturnTypes(JetWhenExpression whenExpression, JetScope scope, List result) { + private void collectAllReturnTypes(JetWhenExpression whenExpression, JetScope scope, List result) { for (JetWhenEntry entry : whenExpression.getEntries()) { JetWhenExpression subWhen = entry.getSubWhen(); if (subWhen != null) { diff --git a/idea/src/org/jetbrains/jet/lang/types/LazySubstitutedPropertyDescriptorImpl.java b/idea/src/org/jetbrains/jet/lang/types/LazySubstitutedPropertyDescriptorImpl.java index cc9b1b0c1ed..e387454c1a4 100644 --- a/idea/src/org/jetbrains/jet/lang/types/LazySubstitutedPropertyDescriptorImpl.java +++ b/idea/src/org/jetbrains/jet/lang/types/LazySubstitutedPropertyDescriptorImpl.java @@ -11,7 +11,7 @@ import java.util.Map; public class LazySubstitutedPropertyDescriptorImpl implements PropertyDescriptor { private final PropertyDescriptor propertyDescriptor; private final Map substitutionContext; - private Type propertyType = null; + private JetType propertyType = null; public LazySubstitutedPropertyDescriptorImpl(@NotNull PropertyDescriptor propertyDescriptor, @NotNull Map substitutionContext) { this.propertyDescriptor = propertyDescriptor; @@ -19,7 +19,7 @@ public class LazySubstitutedPropertyDescriptorImpl implements PropertyDescriptor } @Override - public Type getType() { + public JetType getType() { if (propertyType == null) { propertyType = TypeSubstitutor.INSTANCE.substitute(substitutionContext, propertyDescriptor.getType(), Variance.OUT_VARIANCE); } diff --git a/idea/src/org/jetbrains/jet/lang/types/LazySubstitutingFunctionDescriptor.java b/idea/src/org/jetbrains/jet/lang/types/LazySubstitutingFunctionDescriptor.java index b9c88ed8ca0..56cee728333 100644 --- a/idea/src/org/jetbrains/jet/lang/types/LazySubstitutingFunctionDescriptor.java +++ b/idea/src/org/jetbrains/jet/lang/types/LazySubstitutingFunctionDescriptor.java @@ -56,7 +56,7 @@ public class LazySubstitutingFunctionDescriptor implements FunctionDescriptor { @NotNull @Override - public Type getUnsubstitutedReturnType() { + public JetType getUnsubstitutedReturnType() { return TypeSubstitutor.INSTANCE.substitute(substitutionContext, functionDescriptor.getUnsubstitutedReturnType(), Variance.OUT_VARIANCE); } diff --git a/idea/src/org/jetbrains/jet/lang/types/LazySubstitutingFunctionGroup.java b/idea/src/org/jetbrains/jet/lang/types/LazySubstitutingFunctionGroup.java index d1d6606e3ce..ad18b8aa1fe 100644 --- a/idea/src/org/jetbrains/jet/lang/types/LazySubstitutingFunctionGroup.java +++ b/idea/src/org/jetbrains/jet/lang/types/LazySubstitutingFunctionGroup.java @@ -27,7 +27,7 @@ public class LazySubstitutingFunctionGroup implements FunctionGroup { @NotNull @Override - public Collection getPossiblyApplicableFunctions(@NotNull List typeArguments, @NotNull List positionedValueArgumentTypes) { + public Collection getPossiblyApplicableFunctions(@NotNull List typeArguments, @NotNull List positionedValueArgumentTypes) { Collection possiblyApplicableFunctions = functionGroup.getPossiblyApplicableFunctions(typeArguments, positionedValueArgumentTypes); Collection result = new ArrayList(); for (FunctionDescriptor function : possiblyApplicableFunctions) { diff --git a/idea/src/org/jetbrains/jet/lang/types/NamespaceType.java b/idea/src/org/jetbrains/jet/lang/types/NamespaceType.java index 94fa3383b3d..8560b94cfef 100644 --- a/idea/src/org/jetbrains/jet/lang/types/NamespaceType.java +++ b/idea/src/org/jetbrains/jet/lang/types/NamespaceType.java @@ -11,7 +11,7 @@ import java.util.List; * * @author abreslav */ -public class NamespaceType implements Type { +public class NamespaceType implements JetType { private final String name; private final JetScope memberScope; diff --git a/idea/src/org/jetbrains/jet/lang/types/PropertyDescriptor.java b/idea/src/org/jetbrains/jet/lang/types/PropertyDescriptor.java index 3c7ae7d14e9..143a9ba2cdd 100644 --- a/idea/src/org/jetbrains/jet/lang/types/PropertyDescriptor.java +++ b/idea/src/org/jetbrains/jet/lang/types/PropertyDescriptor.java @@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull; * @author abreslav */ public interface PropertyDescriptor extends DeclarationDescriptor { - Type getType(); + JetType getType(); @Override @NotNull diff --git a/idea/src/org/jetbrains/jet/lang/types/PropertyDescriptorImpl.java b/idea/src/org/jetbrains/jet/lang/types/PropertyDescriptorImpl.java index 2fb75ddf74a..46c52a4957d 100644 --- a/idea/src/org/jetbrains/jet/lang/types/PropertyDescriptorImpl.java +++ b/idea/src/org/jetbrains/jet/lang/types/PropertyDescriptorImpl.java @@ -8,15 +8,15 @@ import java.util.List; * @author abreslav */ public class PropertyDescriptorImpl extends DeclarationDescriptorImpl implements PropertyDescriptor { - private Type type; + private JetType type; - public PropertyDescriptorImpl(@NotNull DeclarationDescriptor containingDeclaration, List attributes, String name, Type type) { + public PropertyDescriptorImpl(@NotNull DeclarationDescriptor containingDeclaration, List attributes, String name, JetType type) { super(containingDeclaration, attributes, name); this.type = type; } @Override - public Type getType() { + public JetType getType() { return type; } diff --git a/idea/src/org/jetbrains/jet/lang/types/TypeConstructor.java b/idea/src/org/jetbrains/jet/lang/types/TypeConstructor.java index 0793d5ab064..cc1d6420b62 100644 --- a/idea/src/org/jetbrains/jet/lang/types/TypeConstructor.java +++ b/idea/src/org/jetbrains/jet/lang/types/TypeConstructor.java @@ -9,11 +9,11 @@ import java.util.List; */ public class TypeConstructor extends AnnotatedImpl { private final List parameters; - private final Collection supertypes; + private final Collection supertypes; private final String debugName; private final boolean sealed; - public TypeConstructor(List attributes, boolean sealed, String debugName, List parameters, Collection supertypes) { + public TypeConstructor(List attributes, boolean sealed, String debugName, List parameters, Collection supertypes) { super(attributes); this.sealed = sealed; this.debugName = debugName; @@ -25,7 +25,7 @@ public class TypeConstructor extends AnnotatedImpl { return parameters; } - public Collection getSupertypes() { + public Collection getSupertypes() { return supertypes; } diff --git a/idea/src/org/jetbrains/jet/lang/types/TypeParameterDescriptor.java b/idea/src/org/jetbrains/jet/lang/types/TypeParameterDescriptor.java index 0935e497969..66155c96b66 100644 --- a/idea/src/org/jetbrains/jet/lang/types/TypeParameterDescriptor.java +++ b/idea/src/org/jetbrains/jet/lang/types/TypeParameterDescriptor.java @@ -11,10 +11,10 @@ import java.util.Set; */ public class TypeParameterDescriptor extends DeclarationDescriptorImpl { private final Variance variance; - private final Set upperBounds; + private final Set upperBounds; private final TypeConstructor typeConstructor; - public TypeParameterDescriptor(@NotNull DeclarationDescriptor containingDeclaration, List attributes, Variance variance, String name, Set upperBounds) { + public TypeParameterDescriptor(@NotNull DeclarationDescriptor containingDeclaration, List attributes, Variance variance, String name, Set upperBounds) { super(containingDeclaration, attributes, name); this.variance = variance; this.upperBounds = upperBounds; @@ -35,7 +35,7 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl { return variance; } - public Set getUpperBounds() { + public Set getUpperBounds() { return upperBounds; } diff --git a/idea/src/org/jetbrains/jet/lang/types/TypeProjection.java b/idea/src/org/jetbrains/jet/lang/types/TypeProjection.java index 1cebb06abef..16448069747 100644 --- a/idea/src/org/jetbrains/jet/lang/types/TypeProjection.java +++ b/idea/src/org/jetbrains/jet/lang/types/TypeProjection.java @@ -7,14 +7,14 @@ import org.jetbrains.annotations.NotNull; */ public class TypeProjection { private final Variance projection; - private final Type type; + private final JetType type; - public TypeProjection(@NotNull Variance projection, @NotNull Type type) { + public TypeProjection(@NotNull Variance projection, @NotNull JetType type) { this.projection = projection; this.type = type; } - public TypeProjection(Type type) { + public TypeProjection(JetType type) { this(Variance.INVARIANT, type); } @@ -22,7 +22,7 @@ public class TypeProjection { return projection; } - public Type getType() { + public JetType getType() { return type; } diff --git a/idea/src/org/jetbrains/jet/lang/types/TypeSubstitutor.java b/idea/src/org/jetbrains/jet/lang/types/TypeSubstitutor.java index 2bc50770c39..a1c624b9b0e 100644 --- a/idea/src/org/jetbrains/jet/lang/types/TypeSubstitutor.java +++ b/idea/src/org/jetbrains/jet/lang/types/TypeSubstitutor.java @@ -12,12 +12,12 @@ public class TypeSubstitutor { private TypeSubstitutor() {} - public Type substitute(@NotNull Type context, @NotNull Type subject, @NotNull Variance howThisTypeIsUsed) { + public JetType substitute(@NotNull JetType context, @NotNull JetType subject, @NotNull Variance howThisTypeIsUsed) { return substitute(getSubstitutionContext(context), subject, howThisTypeIsUsed); } @NotNull - public Type substitute(@NotNull Map substitutionContext, @NotNull Type type, @NotNull Variance howThisTypeIsUsed) { + public JetType substitute(@NotNull Map substitutionContext, @NotNull JetType type, @NotNull Variance howThisTypeIsUsed) { TypeProjection value = substitutionContext.get(type.getConstructor()); if (value != null) { Variance projectionKind = value.getProjectionKind(); @@ -31,7 +31,7 @@ public class TypeSubstitutor { return specializeType(type, substituteInArguments(substitutionContext, type)); } - public Map getSubstitutionContext(Type context) { + public Map getSubstitutionContext(JetType context) { List parameters = context.getConstructor().getParameters(); List contextArguments = context.getArguments(); @@ -50,7 +50,7 @@ public class TypeSubstitutor { @NotNull private TypeProjection substituteInProjection(Map parameterValues, TypeProjection subject) { - @NotNull Type subjectType = subject.getType(); + @NotNull JetType subjectType = subject.getType(); TypeProjection value = parameterValues.get(subjectType.getConstructor()); if (value != null) { return value; @@ -59,7 +59,7 @@ public class TypeSubstitutor { return new TypeProjection(subject.getProjectionKind(), specializeType(subjectType, newArguments)); } - private List substituteInArguments(Map parameterValues, Type subjectType) { + private List substituteInArguments(Map parameterValues, JetType subjectType) { List newArguments = new ArrayList(); for (TypeProjection argument : subjectType.getArguments()) { newArguments.add(substituteInProjection(parameterValues, argument)); @@ -67,13 +67,13 @@ public class TypeSubstitutor { return newArguments; } - private Type specializeType(Type type, List newArguments) { - return new TypeImpl(type.getAttributes(), type.getConstructor(), type.isNullable(), newArguments, type.getMemberScope()); + private JetType specializeType(JetType type, List newArguments) { + return new JetTypeImpl(type.getAttributes(), type.getConstructor(), type.isNullable(), newArguments, type.getMemberScope()); } - public Set substituteInSet(Map substitutionContext, Set types, Variance howTheseTypesWillBeUsed) { - Set result = new HashSet(); - for (Type type : types) { + public Set substituteInSet(Map substitutionContext, Set types, Variance howTheseTypesWillBeUsed) { + Set result = new HashSet(); + for (JetType type : types) { result.add(substitute(substitutionContext, type, howTheseTypesWillBeUsed)); } return result; diff --git a/idea/src/org/jetbrains/jet/lang/types/TypeUtils.java b/idea/src/org/jetbrains/jet/lang/types/TypeUtils.java index d18097975c3..b047a3685a0 100644 --- a/idea/src/org/jetbrains/jet/lang/types/TypeUtils.java +++ b/idea/src/org/jetbrains/jet/lang/types/TypeUtils.java @@ -11,22 +11,22 @@ import java.util.Set; * @author abreslav */ public class TypeUtils { - public static Type makeNullable(Type type) { + public static JetType makeNullable(JetType type) { if (type.isNullable()) { return type; } - return new TypeImpl(type.getAttributes(), type.getConstructor(), true, type.getArguments(), type.getMemberScope()); + return new JetTypeImpl(type.getAttributes(), type.getConstructor(), true, type.getArguments(), type.getMemberScope()); } - public static Type makeNotNullable(Type type) { + public static JetType makeNotNullable(JetType type) { if (!type.isNullable()) { return type; } - return new TypeImpl(type.getAttributes(), type.getConstructor(), false, type.getArguments(), type.getMemberScope()); + return new JetTypeImpl(type.getAttributes(), type.getConstructor(), false, type.getArguments(), type.getMemberScope()); } @Nullable - public static Type intersect(JetTypeChecker typeChecker, Set types) { + public static JetType intersect(JetTypeChecker typeChecker, Set types) { assert !types.isEmpty(); if (types.size() == 1) { @@ -35,11 +35,11 @@ public class TypeUtils { StringBuilder debugName = new StringBuilder(); boolean nullable = false; - for (Iterator iterator = types.iterator(); iterator.hasNext();) { - Type type = iterator.next(); + for (Iterator iterator = types.iterator(); iterator.hasNext();) { + JetType type = iterator.next(); if (!canHaveSubtypes(typeChecker, type)) { - for (Type other : types) { + for (JetType other : types) { if (type != other || !typeChecker.isSubtypeOf(type, other)) { return null; } @@ -57,7 +57,7 @@ public class TypeUtils { List noAttributes = Collections.emptyList(); TypeConstructor constructor = new TypeConstructor(noAttributes, false, debugName.toString(), Collections.emptyList(), types); - return new TypeImpl( + return new JetTypeImpl( noAttributes, constructor, nullable, @@ -65,7 +65,7 @@ public class TypeUtils { JetStandardClasses.STUB); } - private static boolean canHaveSubtypes(JetTypeChecker typeChecker, Type type) { + private static boolean canHaveSubtypes(JetTypeChecker typeChecker, JetType type) { if (type.isNullable()) { return true; } @@ -79,7 +79,7 @@ public class TypeUtils { TypeParameterDescriptor parameterDescriptor = parameters.get(i); TypeProjection typeProjection = arguments.get(i); Variance projectionKind = typeProjection.getProjectionKind(); - Type argument = typeProjection.getType(); + JetType argument = typeProjection.getType(); switch (parameterDescriptor.getVariance()) { case INVARIANT: @@ -128,8 +128,8 @@ public class TypeUtils { return false; } - private static boolean lowerThanBound(JetTypeChecker typeChecker, Type argument, TypeParameterDescriptor parameterDescriptor) { - for (Type bound : parameterDescriptor.getUpperBounds()) { + private static boolean lowerThanBound(JetTypeChecker typeChecker, JetType argument, TypeParameterDescriptor parameterDescriptor) { + for (JetType bound : parameterDescriptor.getUpperBounds()) { if (typeChecker.isSubtypeOf(argument, bound)) { if (!argument.getConstructor().equals(bound.getConstructor())) { return true; @@ -139,7 +139,7 @@ public class TypeUtils { return false; } - public static Type makeNullableIfNeeded(Type type, boolean nullable) { + public static JetType makeNullableIfNeeded(JetType type, boolean nullable) { if (nullable) { return makeNullable(type); } diff --git a/idea/src/org/jetbrains/jet/lang/types/ValueParameterDescriptorImpl.java b/idea/src/org/jetbrains/jet/lang/types/ValueParameterDescriptorImpl.java index fef96c859a3..43e753489fe 100644 --- a/idea/src/org/jetbrains/jet/lang/types/ValueParameterDescriptorImpl.java +++ b/idea/src/org/jetbrains/jet/lang/types/ValueParameterDescriptorImpl.java @@ -12,7 +12,7 @@ public class ValueParameterDescriptorImpl extends PropertyDescriptorImpl impleme private final boolean isVararg; private final int index; - public ValueParameterDescriptorImpl(@NotNull DeclarationDescriptor containingDeclaration, int index, List attributes, String name, Type type, boolean hasDefaultValue, boolean isVararg) { + public ValueParameterDescriptorImpl(@NotNull DeclarationDescriptor containingDeclaration, int index, List attributes, String name, JetType type, boolean hasDefaultValue, boolean isVararg) { super(containingDeclaration, attributes, name, type); this.index = index; this.hasDefaultValue = hasDefaultValue; diff --git a/idea/src/org/jetbrains/jet/resolve/DescriptorUtil.java b/idea/src/org/jetbrains/jet/resolve/DescriptorUtil.java index 9a1f4d28b2e..5f71466b40a 100644 --- a/idea/src/org/jetbrains/jet/resolve/DescriptorUtil.java +++ b/idea/src/org/jetbrains/jet/resolve/DescriptorUtil.java @@ -15,7 +15,7 @@ public class DescriptorUtil { new DeclarationDescriptorVisitor() { @Override public Void visitPropertyDescriptor(PropertyDescriptor descriptor, StringBuilder builder) { - Type type = descriptor.getType(); + JetType type = descriptor.getType(); builder.append(renderName(descriptor)).append(" : ").append(type); return super.visitPropertyDescriptor(descriptor, builder); } @@ -94,7 +94,7 @@ public class DescriptorUtil { private static void renderTypeParameter(TypeParameterDescriptor descriptor, StringBuilder builder) { builder.append(renderName(descriptor)); if (!descriptor.getUpperBounds().isEmpty()) { - Type bound = descriptor.getUpperBounds().iterator().next(); + JetType bound = descriptor.getUpperBounds().iterator().next(); if (bound != JetStandardClasses.getAnyType()) { builder.append(" : ").append(bound); if (descriptor.getUpperBounds().size() > 1) { diff --git a/idea/tests/org/jetbrains/jet/resolve/ExpectedResolveData.java b/idea/tests/org/jetbrains/jet/resolve/ExpectedResolveData.java index bfd938e8863..be7c15c2835 100644 --- a/idea/tests/org/jetbrains/jet/resolve/ExpectedResolveData.java +++ b/idea/tests/org/jetbrains/jet/resolve/ExpectedResolveData.java @@ -126,7 +126,7 @@ public class ExpectedResolveData { continue; } - Type actualType = bindingContext.resolveTypeReference(typeReference); + JetType actualType = bindingContext.resolveTypeReference(typeReference); assertNotNull("Type " + name + " not resolved for reference " + name, actualType); ClassDescriptor expectedClass = lib.getLibraryScope().getClass(name.substring(5)); assertNotNull("Expected class not found: " + name); @@ -156,7 +156,7 @@ public class ExpectedResolveData { PsiElement element = file.findElementAt(position); JetExpression expression = getAncestorOfType(JetExpression.class, element); - Type expressionType = bindingContext.getExpressionType(expression); + JetType expressionType = bindingContext.getExpressionType(expression); TypeConstructor expectedTypeConstructor; if (typeName.startsWith("std::")) { ClassDescriptor expectedClass = lib.getLibraryScope().getClass(typeName.substring(5)); diff --git a/idea/tests/org/jetbrains/jet/resolve/JetResolveTest.java b/idea/tests/org/jetbrains/jet/resolve/JetResolveTest.java index 266eeffded7..faca5442ed9 100644 --- a/idea/tests/org/jetbrains/jet/resolve/JetResolveTest.java +++ b/idea/tests/org/jetbrains/jet/resolve/JetResolveTest.java @@ -83,16 +83,16 @@ public class JetResolveTest extends ExtensibleResolveTestCase { } @NotNull - private FunctionDescriptor standardFunction(ClassDescriptor classDescriptor, String name, Type parameterType) { + private FunctionDescriptor standardFunction(ClassDescriptor classDescriptor, String name, JetType parameterType) { List typeArguments = Collections.emptyList(); return standardFunction(classDescriptor, typeArguments, name, parameterType); } @NotNull - private FunctionDescriptor standardFunction(ClassDescriptor classDescriptor, List typeArguments, String name, Type... parameterType) { + private FunctionDescriptor standardFunction(ClassDescriptor classDescriptor, List typeArguments, String name, JetType... parameterType) { FunctionGroup functionGroup = classDescriptor.getMemberScope(typeArguments).getFunctionGroup(name); - List parameterTypeList = Arrays.asList(parameterType); - Collection functions = functionGroup.getPossiblyApplicableFunctions(Collections.emptyList(), parameterTypeList); + List parameterTypeList = Arrays.asList(parameterType); + Collection functions = functionGroup.getPossiblyApplicableFunctions(Collections.emptyList(), parameterTypeList); for (FunctionDescriptor function : functions) { List unsubstitutedValueParameters = function.getUnsubstitutedValueParameters(); for (int i = 0, unsubstitutedValueParametersSize = unsubstitutedValueParameters.size(); i < unsubstitutedValueParametersSize; i++) { diff --git a/idea/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java b/idea/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java index be1f68561a3..5f4f3ec9b75 100644 --- a/idea/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java +++ b/idea/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java @@ -414,17 +414,17 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase { } private void assertCommonSupertype(String expected, String... types) { - Collection subtypes = new ArrayList(); + Collection subtypes = new ArrayList(); for (String type : types) { subtypes.add(makeType(type)); } - Type result = semanticServices.getTypeChecker().commonSupertype(subtypes); - assertTrue(result + " != " + expected, TypeImpl.equalTypes(result, makeType(expected))); + JetType result = semanticServices.getTypeChecker().commonSupertype(subtypes); + assertTrue(result + " != " + expected, JetTypeImpl.equalTypes(result, makeType(expected))); } private void assertSubtypingRelation(String type1, String type2, boolean expected) { - Type typeNode1 = makeType(type1); - Type typeNode2 = makeType(type2); + JetType typeNode1 = makeType(type1); + JetType typeNode2 = makeType(type2); boolean result = semanticServices.getTypeChecker().isSubtypeOf( typeNode1, typeNode2); @@ -432,40 +432,40 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase { assertTrue(typeNode1 + " is " + modifier + "a subtype of " + typeNode2, result == expected); } - private void assertConvertibleTo(String expression, Type type) { + private void assertConvertibleTo(String expression, JetType type) { JetExpression jetExpression = JetChangeUtil.createExpression(getProject(), expression); assertTrue( expression + " must be convertible to " + type, semanticServices.getTypeChecker().isConvertibleTo(jetExpression, type)); } - private void assertNotConvertibleTo(String expression, Type type) { + private void assertNotConvertibleTo(String expression, JetType type) { JetExpression jetExpression = JetChangeUtil.createExpression(getProject(), expression); assertFalse( expression + " must not be convertible to " + type, semanticServices.getTypeChecker().isConvertibleTo(jetExpression, type)); } - private void assertType(String expression, Type expectedType) { + private void assertType(String expression, JetType expectedType) { Project project = getProject(); JetExpression jetExpression = JetChangeUtil.createExpression(project, expression); - Type type = semanticServices.getTypeInferrer(BindingTrace.DUMMY).getType(classDefinitions.BASIC_SCOPE, jetExpression, false); - assertTrue(type + " != " + expectedType, TypeImpl.equalTypes(type, expectedType)); + JetType type = semanticServices.getTypeInferrer(BindingTrace.DUMMY).getType(classDefinitions.BASIC_SCOPE, jetExpression, false); + assertTrue(type + " != " + expectedType, JetTypeImpl.equalTypes(type, expectedType)); } private void assertErrorType(String expression) { Project project = getProject(); JetExpression jetExpression = JetChangeUtil.createExpression(project, expression); - Type type = semanticServices.getTypeInferrer(BindingTrace.DUMMY).getType(classDefinitions.BASIC_SCOPE, jetExpression, false); + JetType type = semanticServices.getTypeInferrer(BindingTrace.DUMMY).getType(classDefinitions.BASIC_SCOPE, jetExpression, false); assertTrue("Error type expected but " + type + " returned", ErrorType.isErrorType(type)); } private void assertType(String contextType, String expression, String expectedType) { - final Type thisType = makeType(contextType); + final JetType thisType = makeType(contextType); JetScope scope = new JetScopeAdapter(classDefinitions.BASIC_SCOPE) { @NotNull @Override - public Type getThisType() { + public JetType getThisType() { return thisType; } }; @@ -479,16 +479,16 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase { private void assertType(JetScope scope, String expression, String expectedTypeStr) { Project project = getProject(); JetExpression jetExpression = JetChangeUtil.createExpression(project, expression); - Type type = semanticServices.getTypeInferrer(BindingTrace.DUMMY).getType(scope, jetExpression, false); - Type expectedType = expectedTypeStr == null ? null : makeType(expectedTypeStr); + JetType type = semanticServices.getTypeInferrer(BindingTrace.DUMMY).getType(scope, jetExpression, false); + JetType expectedType = expectedTypeStr == null ? null : makeType(expectedTypeStr); assertEquals(expectedType, type); } - private Type makeType(String typeStr) { + private JetType makeType(String typeStr) { return makeType(classDefinitions.BASIC_SCOPE, typeStr); } - private Type makeType(JetScope scope, String typeStr) { + private JetType makeType(JetScope scope, String typeStr) { return new TypeResolver(BindingTrace.DUMMY, semanticServices).resolveType(scope, JetChangeUtil.createType(getProject(), typeStr)); }