Rename getOutType() -> getType()

This commit is contained in:
Andrey Breslav
2012-02-24 18:50:40 +04:00
parent 1f4f4e5c24
commit d22f4eb144
42 changed files with 100 additions and 109 deletions
@@ -68,7 +68,7 @@ public class FunctionDescriptorUtil {
for (int i = 0, unsubstitutedValueParametersSize = unsubstitutedValueParameters.size(); i < unsubstitutedValueParametersSize; i++) {
ValueParameterDescriptor unsubstitutedValueParameter = unsubstitutedValueParameters.get(i);
// TODO : Lazy?
JetType substitutedType = substitutor.substitute(unsubstitutedValueParameter.getOutType(), Variance.IN_VARIANCE);
JetType substitutedType = substitutor.substitute(unsubstitutedValueParameter.getType(), Variance.IN_VARIANCE);
JetType varargElementType = unsubstitutedValueParameter.getVarargElementType();
JetType substituteVarargElementType = varargElementType == null ? null : substitutor.substitute(varargElementType, Variance.IN_VARIANCE);
if (substitutedType == null) return null;
@@ -27,7 +27,6 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import org.jetbrains.jet.lang.resolve.scopes.receivers.TransientReceiver;
import org.jetbrains.jet.lang.types.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -151,7 +150,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
@Override
public JetType getReturnType() {
return getOutType();
return getType();
}
public boolean isVar() {
@@ -213,7 +212,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
List<TypeParameterDescriptor> substitutedTypeParameters = Lists.newArrayList();
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(getTypeParameters(), originalSubstitutor, substitutedDescriptor, substitutedTypeParameters);
JetType originalOutType = getOutType();
JetType originalOutType = getType();
JetType outType = substitutor.substitute(originalOutType, Variance.OUT_VARIANCE);
if (outType == null) {
return null; // TODO : tell the user that the property was projected out
@@ -37,7 +37,7 @@ public class PropertyGetterDescriptor extends PropertyAccessorDescriptor {
}
public void initialize(JetType returnType) {
this.returnType = returnType == null ? getCorrespondingProperty().getOutType() : returnType;
this.returnType = returnType == null ? getCorrespondingProperty().getType() : returnType;
}
@NotNull
@@ -37,7 +37,7 @@ public interface ValueParameterDescriptor extends VariableDescriptor, Annotated
@Override
@NotNull
JetType getOutType();
JetType getType();
@Override
ValueParameterDescriptor getOriginal();
@@ -123,6 +123,6 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
@NotNull
@Override
public ValueParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner) {
return new ValueParameterDescriptorImpl(newOwner, index, Lists.newArrayList(getAnnotations()), getName(), isVar, getOutType(), hasDefaultValue, varargElementType);
return new ValueParameterDescriptorImpl(newOwner, index, Lists.newArrayList(getAnnotations()), getName(), isVar, getType(), hasDefaultValue, varargElementType);
}
}
@@ -27,7 +27,7 @@ import java.util.Collections;
*/
public class VariableAsFunctionDescriptor extends FunctionDescriptorImpl {
public static VariableAsFunctionDescriptor create(@NotNull VariableDescriptor variableDescriptor) {
JetType outType = variableDescriptor.getOutType();
JetType outType = variableDescriptor.getType();
assert outType != null;
VariableAsFunctionDescriptor result = new VariableAsFunctionDescriptor(variableDescriptor);
FunctionDescriptorUtil.initializeFromFunctionType(result, outType, variableDescriptor.getExpectedThisObject());
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.types.TypeSubstitutor;
*/
public interface VariableDescriptor extends CallableDescriptor {
@NotNull
JetType getOutType();
JetType getType();
@Override
@SuppressWarnings({"NullableProblems"})
@@ -52,7 +52,7 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorImpl i
}
@Override
public JetType getOutType() {
public JetType getType() {
return outType;
}
@@ -99,6 +99,6 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorImpl i
@Override
public JetType getReturnType() {
return getOutType();
return getType();
}
}
@@ -106,7 +106,7 @@ public class AnnotationResolver {
List<JetExpression> argumentExpressions = descriptorToArgument.getValue().getArgumentExpressions();
ValueParameterDescriptor parameterDescriptor = descriptorToArgument.getKey();
for (JetExpression argument : argumentExpressions) {
arguments.add(resolveAnnotationArgument(argument, parameterDescriptor.getOutType()));
arguments.add(resolveAnnotationArgument(argument, parameterDescriptor.getType()));
}
}
descriptor.setValueArguments(arguments);
@@ -468,12 +468,12 @@ public class BodyResolver {
private void resolvePropertyInitializer(JetProperty property, PropertyDescriptor propertyDescriptor, JetExpression initializer, JetScope scope) {
//JetFlowInformationProvider flowInformationProvider = context.getDescriptorResolver().computeFlowData(property, initializer); // TODO : flow JET-15
ExpressionTypingServices typeInferrer = context.getSemanticServices().getTypeInferrerServices(trace);
JetType expectedTypeForInitializer = property.getPropertyTypeRef() != null ? propertyDescriptor.getOutType() : NO_EXPECTED_TYPE;
JetType expectedTypeForInitializer = property.getPropertyTypeRef() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
JetType type = typeInferrer.getType(context.getDescriptorResolver().getPropertyDeclarationInnerScope(scope, propertyDescriptor, propertyDescriptor.getTypeParameters(), propertyDescriptor.getReceiverParameter()), initializer, expectedTypeForInitializer);
//
// JetType expectedType = propertyDescriptor.getInType();
// if (expectedType == null) {
// expectedType = propertyDescriptor.getOutType();
// expectedType = propertyDescriptor.getType();
// }
// if (type != null && expectedType != null
// && !context.getSemanticServices().getTypeChecker().isSubtypeOf(type, expectedType)) {
@@ -528,7 +528,7 @@ public class BodyResolver {
JetParameter jetParameter = valueParameters.get(i);
JetExpression defaultValue = jetParameter.getDefaultValue();
if (defaultValue != null) {
typeInferrer.getType(declaringScope, defaultValue, valueParameterDescriptor.getOutType());
typeInferrer.getType(declaringScope, defaultValue, valueParameterDescriptor.getType());
}
}
}
@@ -708,11 +708,11 @@ public class DescriptorResolver {
JetType type;
JetTypeReference typeReference = parameter.getTypeReference();
if (typeReference == null) {
type = propertyDescriptor.getOutType(); // TODO : this maybe unknown at this point
type = propertyDescriptor.getType(); // TODO : this maybe unknown at this point
}
else {
type = typeResolver.resolveType(scope, typeReference);
JetType inType = propertyDescriptor.getOutType();
JetType inType = propertyDescriptor.getType();
if (inType != null) {
if (!TypeUtils.equalTypes(type, inType)) {
trace.report(WRONG_SETTER_PARAMETER_TYPE.on(setter, typeReference, inType));
@@ -762,7 +762,7 @@ public class DescriptorResolver {
if (getter != null) {
List<AnnotationDescriptor> annotations = annotationResolver.resolveAnnotations(scope, getter.getModifierList());
JetType outType = propertyDescriptor.getOutType();
JetType outType = propertyDescriptor.getType();
JetType returnType = outType;
JetTypeReference returnTypeReference = getter.getReturnTypeReference();
if (returnTypeReference != null) {
@@ -782,7 +782,7 @@ public class DescriptorResolver {
}
else {
getterDescriptor = createDefaultGetter(propertyDescriptor);
getterDescriptor.initialize(propertyDescriptor.getOutType());
getterDescriptor.initialize(propertyDescriptor.getType());
}
return getterDescriptor;
}
@@ -872,7 +872,7 @@ public class DescriptorResolver {
PropertySetterDescriptor setter = createDefaultSetter(propertyDescriptor);
propertyDescriptor.initialize(getter, setter);
getter.initialize(propertyDescriptor.getOutType());
getter.initialize(propertyDescriptor.getType());
trace.record(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter, propertyDescriptor);
return propertyDescriptor;
@@ -83,7 +83,7 @@ public interface Importer {
return;
}
if (descriptor instanceof VariableDescriptor) {
JetType type = ((VariableDescriptor) descriptor).getOutType();
JetType type = ((VariableDescriptor) descriptor).getType();
namespaceScope.importScope(type.getMemberScope());
}
else if (descriptor instanceof ClassDescriptor) {
@@ -115,7 +115,7 @@ public class OverridingUtil {
parameters.add(receiverParameter.getType());
}
for (ValueParameterDescriptor valueParameterDescriptor : callableDescriptor.getValueParameters()) {
parameters.add(valueParameterDescriptor.getOutType());
parameters.add(valueParameterDescriptor.getType());
}
return parameters;
}
@@ -540,7 +540,7 @@ public class CallResolver {
// We'll type check the arguments later, with the inferred types expected
TemporaryBindingTrace traceForUnknown = TemporaryBindingTrace.create(temporaryTrace);
ExpressionTypingServices temporaryServices = new ExpressionTypingServices(semanticServices, traceForUnknown);
JetType type = temporaryServices.getType(scope, expression, substituteDontCare.substitute(valueParameterDescriptor.getOutType(), Variance.INVARIANT));
JetType type = temporaryServices.getType(scope, expression, substituteDontCare.substitute(valueParameterDescriptor.getType(), Variance.INVARIANT));
if (type != null && !ErrorUtils.isErrorType(type)) {
constraintSystem.addSubtypingConstraint(VALUE_ARGUMENT.assertSubtyping(type, effectiveExpectedType));
}
@@ -663,7 +663,7 @@ public class CallResolver {
private JetType getEffectiveExpectedType(ValueParameterDescriptor valueParameterDescriptor) {
JetType effectiveExpectedType = valueParameterDescriptor.getVarargElementType();
if (effectiveExpectedType == null) {
effectiveExpectedType = valueParameterDescriptor.getOutType();
effectiveExpectedType = valueParameterDescriptor.getType();
}
return effectiveExpectedType;
}
@@ -1002,7 +1002,7 @@ public class CallResolver {
for (int i = 0; i < valueParameters.size(); i++) {
ValueParameterDescriptor valueParameter = valueParameters.get(i);
JetType expectedType = parameterTypes.get(i);
if (!TypeUtils.equalTypes(expectedType, valueParameter.getOutType())) return false;
if (!TypeUtils.equalTypes(expectedType, valueParameter.getType())) return false;
}
return true;
}
@@ -22,8 +22,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.JetSemanticServices;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.ClassKind;
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.OverridingUtil;
@@ -104,8 +102,8 @@ public class OverloadingConflictResolver {
int fSize = fParams.size();
if (fSize != gParams.size()) return false;
for (int i = 0; i < fSize; i++) {
JetType fParamType = fParams.get(i).getOutType();
JetType gParamType = gParams.get(i).getOutType();
JetType fParamType = fParams.get(i).getType();
JetType gParamType = gParams.get(i).getType();
if (!typeMoreSpecific(fParamType, gParamType)) {
return false;
@@ -93,7 +93,7 @@ public class TaskPrioritizers {
variable = DescriptorUtils.filterNonExtensionProperty(scope.getProperties(name));
}
if (variable != null) {
JetType outType = variable.getOutType();
JetType outType = variable.getType();
if (outType != null && JetStandardClasses.isFunctionType(outType)) {
VariableAsFunctionDescriptor functionDescriptor = VariableAsFunctionDescriptor.create(variable);
if ((functionDescriptor.getReceiverParameter().exists()) == receiverNeeded) {
@@ -234,8 +234,8 @@ public class DataFlowInfo {
// }
//
// @Nullable
// public JetType getOutType(@NotNull VariableDescriptor variableDescriptor) {
// JetType outType = variableDescriptor.getOutType();
// public JetType getType(@NotNull VariableDescriptor variableDescriptor) {
// JetType outType = variableDescriptor.getType();
// if (outType == null) return null;
// if (!outType.isNullable()) return outType;
// NullabilityFlags nullabilityFlags = nullabilityInfo.get(variableDescriptor);
@@ -269,7 +269,7 @@ public class DataFlowInfo {
//
// @NotNull
// public List<JetType> getPossibleTypesForVariable(@NotNull VariableDescriptor variableDescriptor) {
// return getPossibleTypes(variableDescriptor, variableDescriptor.getOutType());
// return getPossibleTypes(variableDescriptor, variableDescriptor.getType());
// }
//
// public List<JetType> getPossibleTypesForReceiver(@NotNull ReceiverDescriptor receiver) {
@@ -57,7 +57,7 @@ public class DataFlowValueFactory {
@NotNull
public DataFlowValue createDataFlowValue(@NotNull VariableDescriptor variableDescriptor) {
JetType type = variableDescriptor.getOutType();
JetType type = variableDescriptor.getType();
return new DataFlowValue(variableDescriptor, type, isStableVariable(variableDescriptor), getImmanentNullability(type));
}
@@ -367,7 +367,7 @@ public class JetStandardClasses {
private static List<JetType> toTypes(List<ValueParameterDescriptor> labeledEntries) {
List<JetType> result = new ArrayList<JetType>();
for (ValueParameterDescriptor entry : labeledEntries) {
result.add(entry.getOutType());
result.add(entry.getType());
}
return result;
}
@@ -607,7 +607,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
temporaryTrace.commit();
VariableDescriptor resultingDescriptor = resolutionResult.getResultingDescriptor();
checkSuper(receiver, resultingDescriptor, context.trace, selectorExpression);
return resultingDescriptor.getOutType();
return resultingDescriptor.getType();
}
if (resolutionResult.isAmbiguity() || resolutionResult.singleResult()) {
temporaryTrace.commit();
@@ -89,7 +89,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
List<JetType> parameterTypes = Lists.newArrayList();
List<ValueParameterDescriptor> valueParameters = functionDescriptor.getValueParameters();
for (ValueParameterDescriptor valueParameter : valueParameters) {
parameterTypes.add(valueParameter.getOutType());
parameterTypes.add(valueParameter.getType());
}
ReceiverDescriptor receiverParameter = functionDescriptor.getReceiverParameter();
JetType receiver = receiverParameter != NO_RECEIVER ? receiverParameter.getType() : null;
@@ -161,7 +161,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
if (functionTypeExpected && !hasDeclaredValueParameters && expectedValueParameters.size() == 1) {
ValueParameterDescriptor valueParameterDescriptor = expectedValueParameters.get(0);
ValueParameterDescriptor it = new ValueParameterDescriptorImpl(
functionDescriptor, 0, Collections.<AnnotationDescriptor>emptyList(), "it", false, valueParameterDescriptor.getOutType(), valueParameterDescriptor.hasDefaultValue(), valueParameterDescriptor.getVarargElementType()
functionDescriptor, 0, Collections.<AnnotationDescriptor>emptyList(), "it", false, valueParameterDescriptor.getType(), valueParameterDescriptor.hasDefaultValue(), valueParameterDescriptor.getVarargElementType()
);
valueParameterDescriptors.add(it);
context.trace.record(AUTO_CREATED_IT, it);
@@ -177,7 +177,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
}
else {
if (expectedValueParameters != null && i < expectedValueParameters.size()) {
type = expectedValueParameters.get(i).getOutType();
type = expectedValueParameters.get(i).getType();
}
else {
context.trace.report(CANNOT_INFER_PARAMETER_TYPE.on(declaredParameter));
@@ -248,7 +248,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
VariableDescriptor variableDescriptor;
if (typeReference != null) {
variableDescriptor = context.getDescriptorResolver().resolveLocalVariableDescriptor(context.scope.getContainingDeclaration(), context.scope, loopParameter);
JetType actualParameterType = variableDescriptor.getOutType();
JetType actualParameterType = variableDescriptor.getType();
if (expectedParameterType != null &&
actualParameterType != null &&
!context.semanticServices.getTypeChecker().isSubtypeOf(expectedParameterType, actualParameterType)) {
@@ -377,7 +377,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
if (hasNextProperty == null) {
return null;
} else {
JetType hasNextReturnType = hasNextProperty.getOutType();
JetType hasNextReturnType = hasNextProperty.getType();
if (hasNextReturnType == null) {
// TODO : accessibility
context.trace.report(HAS_NEXT_MUST_BE_READABLE.on(loopRange));
@@ -401,7 +401,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
if (catchParameter != null) {
VariableDescriptor variableDescriptor = context.getDescriptorResolver().resolveLocalVariableDescriptor(context.scope.getContainingDeclaration(), context.scope, catchParameter);
JetType throwableType = context.semanticServices.getStandardLibrary().getThrowable().getDefaultType();
DataFlowUtils.checkType(variableDescriptor.getOutType(), catchParameter, context.replaceExpectedType(throwableType));
DataFlowUtils.checkType(variableDescriptor.getType(), catchParameter, context.replaceExpectedType(throwableType));
if (catchBody != null) {
WritableScope catchScope = newWritableScopeImpl(context).setDebugName("Catch scope");
catchScope.addVariableDescriptor(variableDescriptor);
@@ -150,7 +150,7 @@ public class ExpressionTypingUtils {
public static boolean isVariableIterable(@NotNull Project project, @NotNull VariableDescriptor variableDescriptor, @NotNull JetScope scope) {
JetExpression expression = JetPsiFactory.createExpression(project, "fake");
ExpressionReceiver expressionReceiver = new ExpressionReceiver(expression, variableDescriptor.getOutType());
ExpressionReceiver expressionReceiver = new ExpressionReceiver(expression, variableDescriptor.getType());
ExpressionTypingContext context = ExpressionTypingContext.newContext(
project,
JetSemanticServices.createSemanticServices(project),
@@ -109,7 +109,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
VariableDescriptor propertyDescriptor = context.getDescriptorResolver().resolveLocalVariableDescriptor(scope.getContainingDeclaration(), scope, property, context.dataFlowInfo);
JetExpression initializer = property.getInitializer();
if (property.getPropertyTypeRef() != null && initializer != null) {
JetType outType = propertyDescriptor.getOutType();
JetType outType = propertyDescriptor.getType();
JetType initializerType = facade.getType(initializer, context.replaceExpectedType(outType).replaceScope(scope));
}
@@ -152,7 +152,7 @@ public class DescriptorRenderer implements Renderer {
@Override
public Void visitVariableDescriptor(VariableDescriptor descriptor, StringBuilder builder) {
String typeString = renderPropertyPrefixAndComputeTypeString(builder, Collections.<TypeParameterDescriptor>emptyList(), ReceiverDescriptor.NO_RECEIVER, descriptor.getOutType());
String typeString = renderPropertyPrefixAndComputeTypeString(builder, Collections.<TypeParameterDescriptor>emptyList(), ReceiverDescriptor.NO_RECEIVER, descriptor.getType());
renderName(descriptor, builder);
builder.append(" : ").append(escape(typeString));
return super.visitVariableDescriptor(descriptor, builder);
@@ -188,7 +188,7 @@ public class DescriptorRenderer implements Renderer {
String typeString = renderPropertyPrefixAndComputeTypeString(
builder, descriptor.getTypeParameters(),
descriptor.getReceiverParameter(),
descriptor.getOutType());
descriptor.getType());
renderName(descriptor, builder);
builder.append(" : ").append(escape(typeString));
return null;