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
@@ -119,7 +119,7 @@ public abstract class ClassBodyCodegen {
if(state.getStandardLibrary().isVolatile(propertyDescriptor)) { if(state.getStandardLibrary().isVolatile(propertyDescriptor)) {
modifiers |= Opcodes.ACC_VOLATILE; modifiers |= Opcodes.ACC_VOLATILE;
} }
v.newField(p, modifiers, p.getName(), state.getTypeMapper().mapType(propertyDescriptor.getOutType()).getDescriptor(), null, null); v.newField(p, modifiers, p.getName(), state.getTypeMapper().mapType(propertyDescriptor.getType()).getDescriptor(), null, null);
} }
} }
} }
@@ -113,7 +113,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
final String funClass = getInternalClassName(funDescriptor); final String funClass = getInternalClassName(funDescriptor);
signatureWriter.visitClassType(funClass); signatureWriter.visitClassType(funClass);
for (ValueParameterDescriptor parameter : parameters) { for (ValueParameterDescriptor parameter : parameters) {
appendType(signatureWriter, parameter.getOutType(), '='); appendType(signatureWriter, parameter.getType(), '=');
} }
appendType(signatureWriter, funDescriptor.getReturnType(), '='); appendType(signatureWriter, funDescriptor.getReturnType(), '=');
@@ -233,7 +233,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
final List<ValueParameterDescriptor> params = funDescriptor.getValueParameters(); final List<ValueParameterDescriptor> params = funDescriptor.getValueParameters();
for (ValueParameterDescriptor param : params) { for (ValueParameterDescriptor param : params) {
StackValue.local(count, JetTypeMapper.TYPE_OBJECT).put(JetTypeMapper.TYPE_OBJECT, iv); StackValue.local(count, JetTypeMapper.TYPE_OBJECT).put(JetTypeMapper.TYPE_OBJECT, iv);
StackValue.onStack(JetTypeMapper.TYPE_OBJECT).upcast(state.getTypeMapper().mapType(param.getOutType()), iv); StackValue.onStack(JetTypeMapper.TYPE_OBJECT).upcast(state.getTypeMapper().mapType(param.getType()), iv);
count++; count++;
} }
@@ -280,7 +280,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
for (DeclarationDescriptor descriptor : closure.keySet()) { for (DeclarationDescriptor descriptor : closure.keySet()) {
if(descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) { if(descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) {
final Type sharedVarType = exprContext.getTypeMapper().getSharedVarType(descriptor); final Type sharedVarType = exprContext.getTypeMapper().getSharedVarType(descriptor);
final Type type = sharedVarType != null ? sharedVarType : state.getTypeMapper().mapType(((VariableDescriptor) descriptor).getOutType()); final Type type = sharedVarType != null ? sharedVarType : state.getTypeMapper().mapType(((VariableDescriptor) descriptor).getType());
argTypes[i++] = type; argTypes[i++] = type;
} }
else if(CodegenUtil.isNamedFun(descriptor, state.getBindingContext()) && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) { else if(CodegenUtil.isNamedFun(descriptor, state.getBindingContext()) && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
@@ -257,13 +257,13 @@ public abstract class CodegenContext {
CallableMemberDescriptor.Kind.DECLARATION CallableMemberDescriptor.Kind.DECLARATION
); );
JetType receiverType = pd.getReceiverParameter().exists() ? pd.getReceiverParameter().getType() : null; JetType receiverType = pd.getReceiverParameter().exists() ? pd.getReceiverParameter().getType() : null;
myAccessor.setType(pd.getOutType(), Collections.<TypeParameterDescriptor>emptyList(), pd.getExpectedThisObject(), receiverType); myAccessor.setType(pd.getType(), Collections.<TypeParameterDescriptor>emptyList(), pd.getExpectedThisObject(), receiverType);
PropertyGetterDescriptor pgd = new PropertyGetterDescriptor( PropertyGetterDescriptor pgd = new PropertyGetterDescriptor(
myAccessor, Collections.<AnnotationDescriptor>emptyList(), myAccessor.getModality(), myAccessor, Collections.<AnnotationDescriptor>emptyList(), myAccessor.getModality(),
myAccessor.getVisibility(), myAccessor.getVisibility(),
false, false, CallableMemberDescriptor.Kind.DECLARATION); false, false, CallableMemberDescriptor.Kind.DECLARATION);
pgd.initialize(myAccessor.getOutType()); pgd.initialize(myAccessor.getType());
PropertySetterDescriptor psd = new PropertySetterDescriptor( PropertySetterDescriptor psd = new PropertySetterDescriptor(
myAccessor, Collections.<AnnotationDescriptor>emptyList(), myAccessor.getModality(), myAccessor, Collections.<AnnotationDescriptor>emptyList(), myAccessor.getModality(),
@@ -353,7 +353,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
JetType iteratorType = iteratorDescriptor.getReturnType(); JetType iteratorType = iteratorDescriptor.getReturnType();
Type asmIterType = boxType(asmType(iteratorType)); Type asmIterType = boxType(asmType(iteratorType));
JetType paramType = parameterDescriptor.getOutType(); JetType paramType = parameterDescriptor.getType();
Type asmParamType = asmType(paramType); Type asmParamType = asmType(paramType);
int iteratorVar = myFrameMap.enterTemp(); int iteratorVar = myFrameMap.enterTemp();
@@ -428,7 +428,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
} }
public void invoke() { public void invoke() {
JetType paramType = parameterDescriptor.getOutType(); JetType paramType = parameterDescriptor.getType();
Type asmParamType = asmType(paramType); Type asmParamType = asmType(paramType);
myFrameMap.enter(parameterDescriptor, asmParamType.getSize()); myFrameMap.enter(parameterDescriptor, asmParamType.getSize());
@@ -801,7 +801,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
if(entry.getKey() instanceof VariableDescriptor && !(entry.getKey() instanceof PropertyDescriptor)) { if(entry.getKey() instanceof VariableDescriptor && !(entry.getKey() instanceof PropertyDescriptor)) {
Type sharedVarType = typeMapper.getSharedVarType(entry.getKey()); Type sharedVarType = typeMapper.getSharedVarType(entry.getKey());
if(sharedVarType == null) if(sharedVarType == null)
sharedVarType = state.getTypeMapper().mapType(((VariableDescriptor) entry.getKey()).getOutType()); sharedVarType = state.getTypeMapper().mapType(((VariableDescriptor) entry.getKey()).getType());
consArgTypes.add(sharedVarType); consArgTypes.add(sharedVarType);
entry.getValue().getOuterValue().put(sharedVarType, v); entry.getValue().getOuterValue().put(sharedVarType, v);
} }
@@ -833,7 +833,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
assert variableDescriptor != null; assert variableDescriptor != null;
final Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor); final Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor);
final Type type = sharedVarType != null ? sharedVarType : asmType(variableDescriptor.getOutType()); final Type type = sharedVarType != null ? sharedVarType : asmType(variableDescriptor.getType());
myFrameMap.enter(variableDescriptor, type.getSize()); myFrameMap.enter(variableDescriptor, type.getSize());
} }
@@ -874,7 +874,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
int index = myFrameMap.leave(variableDescriptor); int index = myFrameMap.leave(variableDescriptor);
final Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor); final Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor);
final Type type = sharedVarType != null ? sharedVarType : asmType(variableDescriptor.getOutType()); final Type type = sharedVarType != null ? sharedVarType : asmType(variableDescriptor.getType());
if(sharedVarType != null) { if(sharedVarType != null) {
v.aconst(null); v.aconst(null);
v.store(index, TYPE_OBJECT); v.store(index, TYPE_OBJECT);
@@ -983,7 +983,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
if (index >= 0) { if (index >= 0) {
if(descriptor instanceof VariableDescriptor) { if(descriptor instanceof VariableDescriptor) {
Type sharedVarType = typeMapper.getSharedVarType(descriptor); Type sharedVarType = typeMapper.getSharedVarType(descriptor);
final JetType outType = ((VariableDescriptor) descriptor).getOutType(); final JetType outType = ((VariableDescriptor) descriptor).getType();
if(sharedVarType != null) { if(sharedVarType != null) {
return StackValue.shared(index, asmType(outType)); return StackValue.shared(index, asmType(outType));
} }
@@ -1231,7 +1231,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
ownerParam = callableMethod.getDefaultImplParam(); ownerParam = callableMethod.getDefaultImplParam();
} }
return StackValue.property(propertyDescriptor.getName(), owner, ownerParam, asmType(propertyDescriptor.getOutType()), isStatic, isInterface, isSuper, getter, setter, invokeOpcode); return StackValue.property(propertyDescriptor.getName(), owner, ownerParam, asmType(propertyDescriptor.getType()), isStatic, isInterface, isSuper, getter, setter, invokeOpcode);
} }
@Override @Override
@@ -1511,7 +1511,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
} }
else if(resolvedValueArgument instanceof VarargValueArgument) { else if(resolvedValueArgument instanceof VarargValueArgument) {
VarargValueArgument valueArgument = (VarargValueArgument) resolvedValueArgument; VarargValueArgument valueArgument = (VarargValueArgument) resolvedValueArgument;
JetType outType = valueParameterDescriptor.getOutType(); JetType outType = valueParameterDescriptor.getType();
Type type = asmType(outType); Type type = asmType(outType);
assert type.getSort() == Type.ARRAY; assert type.getSort() == Type.ARRAY;
@@ -1682,7 +1682,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
StackValue leftValue = gen(expr); StackValue leftValue = gen(expr);
FunctionDescriptor op = (FunctionDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference()); FunctionDescriptor op = (FunctionDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
assert op != null; assert op != null;
leftValue.put(asmType(op.getValueParameters().get(0).getOutType()), v); leftValue.put(asmType(op.getValueParameters().get(0).getType()), v);
genToJVMStack(expression.getRight()); genToJVMStack(expression.getRight());
v.swap(); v.swap();
invokeFunctionNoParams(op, Type.BOOLEAN_TYPE, v); invokeFunctionNoParams(op, Type.BOOLEAN_TYPE, v);
@@ -2209,7 +2209,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
final Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor); final Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor);
assert variableDescriptor != null; assert variableDescriptor != null;
Type varType = asmType(variableDescriptor.getOutType()); Type varType = asmType(variableDescriptor.getType());
if(sharedVarType != null) { if(sharedVarType != null) {
v.anew(sharedVarType); v.anew(sharedVarType);
v.dup(); v.dup();
@@ -2371,7 +2371,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
final List<JetExpression> indices = expression.getIndexExpressions(); final List<JetExpression> indices = expression.getIndexExpressions();
FunctionDescriptor operationDescriptor = (FunctionDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, expression); FunctionDescriptor operationDescriptor = (FunctionDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, expression);
assert operationDescriptor != null; assert operationDescriptor != null;
if (arrayType.getSort() == Type.ARRAY && indices.size() == 1 && operationDescriptor.getValueParameters().get(0).getOutType().equals(state.getStandardLibrary().getIntType())) { if (arrayType.getSort() == Type.ARRAY && indices.size() == 1 && operationDescriptor.getValueParameters().get(0).getType().equals(state.getStandardLibrary().getIntType())) {
gen(array, arrayType); gen(array, arrayType);
for (JetExpression index : indices) { for (JetExpression index : indices) {
gen(index, Type.INT_TYPE); gen(index, Type.INT_TYPE);
@@ -2499,7 +2499,7 @@ If finally block is present, its last expression is the value of try expression.
VariableDescriptor descriptor = bindingContext.get(BindingContext.VALUE_PARAMETER, clause.getCatchParameter()); VariableDescriptor descriptor = bindingContext.get(BindingContext.VALUE_PARAMETER, clause.getCatchParameter());
assert descriptor != null; assert descriptor != null;
Type descriptorType = asmType(descriptor.getOutType()); Type descriptorType = asmType(descriptor.getType());
myFrameMap.enter(descriptor, 1); myFrameMap.enter(descriptor, 1);
int index = lookupLocal(descriptor); int index = lookupLocal(descriptor);
v.store(index, descriptorType); v.store(index, descriptorType);
@@ -2614,7 +2614,7 @@ If finally block is present, its last expression is the value of try expression.
final JetProperty var = ((JetBindingPattern) pattern).getVariableDeclaration(); final JetProperty var = ((JetBindingPattern) pattern).getVariableDeclaration();
final VariableDescriptor variableDescriptor = bindingContext.get(BindingContext.VARIABLE, var); final VariableDescriptor variableDescriptor = bindingContext.get(BindingContext.VARIABLE, var);
assert variableDescriptor != null; assert variableDescriptor != null;
final Type varType = asmType(variableDescriptor.getOutType()); final Type varType = asmType(variableDescriptor.getType());
myFrameMap.enter(variableDescriptor, varType.getSize()); myFrameMap.enter(variableDescriptor, varType.getSize());
expressionToMatch.dupReceiver(v); expressionToMatch.dupReceiver(v);
expressionToMatch.put(varType, v); expressionToMatch.put(varType, v);
@@ -153,7 +153,7 @@ public class FunctionCodegen {
if(parameterDescriptor.hasDefaultValue()) { if(parameterDescriptor.hasDefaultValue()) {
av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_HAS_DEFAULT_VALUE_FIELD, true); av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_HAS_DEFAULT_VALUE_FIELD, true);
} }
if(parameterDescriptor.getOutType().isNullable()) { if(parameterDescriptor.getType().isNullable()) {
av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD, true); av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD, true);
} }
if (jvmSignature.getKotlinParameterTypes() != null && jvmSignature.getKotlinParameterTypes().get(i) != null) { if (jvmSignature.getKotlinParameterTypes() != null && jvmSignature.getKotlinParameterTypes().get(i) != null) {
@@ -205,7 +205,7 @@ public class FunctionCodegen {
for (ValueParameterDescriptor parameter : paramDescrs) { for (ValueParameterDescriptor parameter : paramDescrs) {
Type sharedVarType = typeMapper.getSharedVarType(parameter); Type sharedVarType = typeMapper.getSharedVarType(parameter);
if (sharedVarType != null) { if (sharedVarType != null) {
Type localVarType = typeMapper.mapType(parameter.getOutType()); Type localVarType = typeMapper.mapType(parameter.getType());
int index = frameMap.getIndex(parameter); int index = frameMap.getIndex(parameter);
mv.visitTypeInsn(NEW, sharedVarType.getInternalName()); mv.visitTypeInsn(NEW, sharedVarType.getInternalName());
mv.visitInsn(DUP); mv.visitInsn(DUP);
@@ -239,7 +239,7 @@ public class FunctionCodegen {
} }
for (ValueParameterDescriptor parameter : paramDescrs) { for (ValueParameterDescriptor parameter : paramDescrs) {
Type type = typeMapper.mapType(parameter.getOutType()); Type type = typeMapper.mapType(parameter.getType());
// TODO: specify signature // TODO: specify signature
mv.visitLocalVariable(parameter.getName(), type.getDescriptor(), null, methodBegin, methodEnd, k); mv.visitLocalVariable(parameter.getName(), type.getDescriptor(), null, methodBegin, methodEnd, k);
k += type.getSize(); k += type.getSize();
@@ -451,7 +451,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
for (DeclarationDescriptor descriptor : closure.closure.keySet()) { for (DeclarationDescriptor descriptor : closure.closure.keySet()) {
if(descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) { if(descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) {
final Type sharedVarType = typeMapper.getSharedVarType(descriptor); final Type sharedVarType = typeMapper.getSharedVarType(descriptor);
final Type type = sharedVarType != null ? sharedVarType : state.getTypeMapper().mapType(((VariableDescriptor) descriptor).getOutType()); final Type type = sharedVarType != null ? sharedVarType : state.getTypeMapper().mapType(((VariableDescriptor) descriptor).getType());
consArgTypes.add(insert++, new JvmMethodParameterSignature(type, "", JvmMethodParameterKind.SHARED_VAR)); consArgTypes.add(insert++, new JvmMethodParameterSignature(type, "", JvmMethodParameterKind.SHARED_VAR));
} }
else if(descriptor instanceof FunctionDescriptor) { else if(descriptor instanceof FunctionDescriptor) {
@@ -612,7 +612,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
if(varDescr instanceof VariableDescriptor && !(varDescr instanceof PropertyDescriptor)) { if(varDescr instanceof VariableDescriptor && !(varDescr instanceof PropertyDescriptor)) {
Type sharedVarType = typeMapper.getSharedVarType(varDescr); Type sharedVarType = typeMapper.getSharedVarType(varDescr);
if(sharedVarType == null) { if(sharedVarType == null) {
sharedVarType = typeMapper.mapType(((VariableDescriptor) varDescr).getOutType()); sharedVarType = typeMapper.mapType(((VariableDescriptor) varDescr).getType());
} }
iv.load(0, JetTypeMapper.TYPE_OBJECT); iv.load(0, JetTypeMapper.TYPE_OBJECT);
iv.load(k, StackValue.refType(sharedVarType)); iv.load(k, StackValue.refType(sharedVarType));
@@ -628,7 +628,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
for (JetParameter parameter : constructorParameters) { for (JetParameter parameter : constructorParameters) {
if (parameter.getValOrVarNode() != null) { if (parameter.getValOrVarNode() != null) {
VariableDescriptor descriptor = paramDescrs.get(curParam); VariableDescriptor descriptor = paramDescrs.get(curParam);
Type type = typeMapper.mapType(descriptor.getOutType()); Type type = typeMapper.mapType(descriptor.getType());
iv.load(0, classType); iv.load(0, classType);
iv.load(frameMap.getIndex(descriptor), type); iv.load(frameMap.getIndex(descriptor), type);
iv.putfield(classname, descriptor.getName(), type.getDescriptor()); iv.putfield(classname, descriptor.getName(), type.getDescriptor());
@@ -864,9 +864,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
if(compileTimeValue != null) { if(compileTimeValue != null) {
assert compileTimeValue != null; assert compileTimeValue != null;
Object value = compileTimeValue.getValue(); Object value = compileTimeValue.getValue();
Type type = typeMapper.mapType(propertyDescriptor.getOutType()); Type type = typeMapper.mapType(propertyDescriptor.getType());
if(JetTypeMapper.isPrimitive(type)) { if(JetTypeMapper.isPrimitive(type)) {
if( !propertyDescriptor.getOutType().isNullable() && value instanceof Number) { if( !propertyDescriptor.getType().isNullable() && value instanceof Number) {
if(type == Type.INT_TYPE && ((Number)value).intValue() == 0) if(type == Type.INT_TYPE && ((Number)value).intValue() == 0)
continue; continue;
if(type == Type.BYTE_TYPE && ((Number)value).byteValue() == 0) if(type == Type.BYTE_TYPE && ((Number)value).byteValue() == 0)
@@ -892,12 +892,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
} }
iv.load(0, JetTypeMapper.TYPE_OBJECT); iv.load(0, JetTypeMapper.TYPE_OBJECT);
Type type = codegen.expressionType(initializer); Type type = codegen.expressionType(initializer);
if(propertyDescriptor.getOutType().isNullable()) if(propertyDescriptor.getType().isNullable())
type = JetTypeMapper.boxType(type); type = JetTypeMapper.boxType(type);
codegen.gen(initializer, type); codegen.gen(initializer, type);
// @todo write directly to the field. Fix test excloset.jet::test6 // @todo write directly to the field. Fix test excloset.jet::test6
String owner = typeMapper.getOwner(propertyDescriptor, OwnerKind.IMPLEMENTATION); String owner = typeMapper.getOwner(propertyDescriptor, OwnerKind.IMPLEMENTATION);
StackValue.property(propertyDescriptor.getName(), owner, owner, typeMapper.mapType(propertyDescriptor.getOutType()), false, false, false, null, null, 0).store(iv); StackValue.property(propertyDescriptor.getName(), owner, owner, typeMapper.mapType(propertyDescriptor.getType()), false, false, false, null, null, 0).store(iv);
} }
} }
@@ -488,7 +488,7 @@ public class JetTypeMapper {
for (ValueParameterDescriptor parameter : parameters) { for (ValueParameterDescriptor parameter : parameters) {
signatureVisitor.writeParameterType(JvmMethodParameterKind.VALUE); signatureVisitor.writeParameterType(JvmMethodParameterKind.VALUE);
mapType(parameter.getOutType(), signatureVisitor); mapType(parameter.getType(), signatureVisitor);
signatureVisitor.writeParameterTypeEnd(); signatureVisitor.writeParameterTypeEnd();
} }
@@ -576,7 +576,7 @@ public class JetTypeMapper {
} }
for (ValueParameterDescriptor parameter : parameters) { for (ValueParameterDescriptor parameter : parameters) {
signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE); signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE);
mapType(parameter.getOutType(), signatureWriter); mapType(parameter.getType(), signatureWriter);
signatureWriter.writeParameterTypeEnd(); signatureWriter.writeParameterTypeEnd();
} }
@@ -617,7 +617,7 @@ public class JetTypeMapper {
signatureWriter.writeParametersEnd(); signatureWriter.writeParametersEnd();
signatureWriter.writeReturnType(); signatureWriter.writeReturnType();
mapType(descriptor.getOutType(), signatureWriter); mapType(descriptor.getType(), signatureWriter);
signatureWriter.writeReturnTypeEnd(); signatureWriter.writeReturnTypeEnd();
JvmMethodSignature jvmMethodSignature = signatureWriter.makeJvmMethodSignature(name); JvmMethodSignature jvmMethodSignature = signatureWriter.makeJvmMethodSignature(name);
@@ -636,7 +636,7 @@ public class JetTypeMapper {
writeFormalTypeParameters(descriptor.getTypeParameters(), signatureWriter); writeFormalTypeParameters(descriptor.getTypeParameters(), signatureWriter);
JetType outType = descriptor.getOutType(); JetType outType = descriptor.getType();
signatureWriter.writeParametersStart(); signatureWriter.writeParametersStart();
@@ -687,7 +687,7 @@ public class JetTypeMapper {
for (ValueParameterDescriptor parameter : parameters) { for (ValueParameterDescriptor parameter : parameters) {
signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE); signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE);
mapType(parameter.getOutType(), signatureWriter); mapType(parameter.getType(), signatureWriter);
signatureWriter.writeParameterTypeEnd(); signatureWriter.writeParameterTypeEnd();
} }
@@ -864,7 +864,7 @@ public class JetTypeMapper {
else if (descriptor instanceof VariableDescriptor) { else if (descriptor instanceof VariableDescriptor) {
Boolean aBoolean = bindingContext.get(BindingContext.MUST_BE_WRAPPED_IN_A_REF, (VariableDescriptor) descriptor); Boolean aBoolean = bindingContext.get(BindingContext.MUST_BE_WRAPPED_IN_A_REF, (VariableDescriptor) descriptor);
if (aBoolean != null && aBoolean) { if (aBoolean != null && aBoolean) {
JetType outType = ((VariableDescriptor) descriptor).getOutType(); JetType outType = ((VariableDescriptor) descriptor).getType();
return StackValue.sharedTypeForType(mapType(outType)); return StackValue.sharedTypeForType(mapType(outType));
} }
else { else {
@@ -61,7 +61,7 @@ public class ObjectOrClosureCodegen {
if (idx < 0) return null; if (idx < 0) return null;
final Type sharedVarType = state.getTypeMapper().getSharedVarType(vd); final Type sharedVarType = state.getTypeMapper().getSharedVarType(vd);
Type localType = state.getTypeMapper().mapType(vd.getOutType()); Type localType = state.getTypeMapper().mapType(vd.getType());
final Type type = sharedVarType != null ? sharedVarType : localType; final Type type = sharedVarType != null ? sharedVarType : localType;
StackValue outerValue = StackValue.local(idx, type); StackValue outerValue = StackValue.local(idx, type);
@@ -30,10 +30,6 @@ import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type; import org.objectweb.asm.Type;
import org.objectweb.asm.commons.InstructionAdapter; import org.objectweb.asm.commons.InstructionAdapter;
import org.objectweb.asm.commons.Method;
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static org.objectweb.asm.Opcodes.ACC_SYNTHETIC;
/** /**
* @author max * @author max
@@ -99,7 +95,7 @@ public class PropertyCodegen {
if(state.getStandardLibrary().isVolatile(propertyDescriptor)) { if(state.getStandardLibrary().isVolatile(propertyDescriptor)) {
modifiers |= Opcodes.ACC_VOLATILE; modifiers |= Opcodes.ACC_VOLATILE;
} }
FieldVisitor fieldVisitor = v.newField(p, modifiers, p.getName(), state.getTypeMapper().mapType(propertyDescriptor.getOutType()).getDescriptor(), null, value); FieldVisitor fieldVisitor = v.newField(p, modifiers, p.getName(), state.getTypeMapper().mapType(propertyDescriptor.getType()).getDescriptor(), null, value);
AnnotationCodegen.forField(fieldVisitor).genAnnotations(propertyDescriptor, state.getTypeMapper()); AnnotationCodegen.forField(fieldVisitor).genAnnotations(propertyDescriptor, state.getTypeMapper());
} }
} }
@@ -179,7 +175,7 @@ public class PropertyCodegen {
if (kind != OwnerKind.NAMESPACE) { if (kind != OwnerKind.NAMESPACE) {
iv.load(0, JetTypeMapper.TYPE_OBJECT); iv.load(0, JetTypeMapper.TYPE_OBJECT);
} }
final Type type = state.getTypeMapper().mapType(propertyDescriptor.getOutType()); final Type type = state.getTypeMapper().mapType(propertyDescriptor.getType());
if (kind instanceof OwnerKind.DelegateKind) { if (kind instanceof OwnerKind.DelegateKind) {
OwnerKind.DelegateKind dk = (OwnerKind.DelegateKind) kind; OwnerKind.DelegateKind dk = (OwnerKind.DelegateKind) kind;
dk.getDelegate().put(JetTypeMapper.TYPE_OBJECT, iv); dk.getDelegate().put(JetTypeMapper.TYPE_OBJECT, iv);
@@ -240,7 +236,7 @@ public class PropertyCodegen {
if (v.generateCode() && (!isTrait || kind instanceof OwnerKind.DelegateKind)) { if (v.generateCode() && (!isTrait || kind instanceof OwnerKind.DelegateKind)) {
mv.visitCode(); mv.visitCode();
InstructionAdapter iv = new InstructionAdapter(mv); InstructionAdapter iv = new InstructionAdapter(mv);
final Type type = state.getTypeMapper().mapType(propertyDescriptor.getOutType()); final Type type = state.getTypeMapper().mapType(propertyDescriptor.getType());
int paramCode = 0; int paramCode = 0;
if (kind != OwnerKind.NAMESPACE) { if (kind != OwnerKind.NAMESPACE) {
iv.load(0, JetTypeMapper.TYPE_OBJECT); iv.load(0, JetTypeMapper.TYPE_OBJECT);
@@ -593,7 +593,7 @@ public abstract class StackValue {
List<ValueParameterDescriptor> valueParameters = resolvedGetCall.getResultingDescriptor().getValueParameters(); List<ValueParameterDescriptor> valueParameters = resolvedGetCall.getResultingDescriptor().getValueParameters();
int firstParamIndex = -1; int firstParamIndex = -1;
for(int i = valueParameters.size()-1; i >= 0; --i) { for(int i = valueParameters.size()-1; i >= 0; --i) {
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getOutType()); Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType());
int sz = type.getSize(); int sz = type.getSize();
frame.enterTemp(sz); frame.enterTemp(sz);
lastIndex += sz; lastIndex += sz;
@@ -673,7 +673,7 @@ public abstract class StackValue {
int index = firstParamIndex; int index = firstParamIndex;
for(int i = 0; i != valueParameters.size(); ++i) { for(int i = 0; i != valueParameters.size(); ++i) {
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getOutType()); Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType());
int sz = type.getSize(); int sz = type.getSize();
v.load(index-sz, type); v.load(index-sz, type);
index -= sz; index -= sz;
@@ -701,7 +701,7 @@ public abstract class StackValue {
index = firstParamIndex; index = firstParamIndex;
for(int i = 0; i != valueParameters.size(); ++i) { for(int i = 0; i != valueParameters.size(); ++i) {
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getOutType()); Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType());
int sz = type.getSize(); int sz = type.getSize();
v.load(index-sz, type); v.load(index-sz, type);
index -= sz; index -= sz;
@@ -725,7 +725,7 @@ public abstract class StackValue {
return false; return false;
for (ValueParameterDescriptor valueParameter : valueParameters) { for (ValueParameterDescriptor valueParameter : valueParameters) {
if (codegen.typeMapper.mapType(valueParameter.getOutType()).getSize() != 1) if (codegen.typeMapper.mapType(valueParameter.getType()).getSize() != 1)
return false; return false;
} }
@@ -1240,7 +1240,7 @@ public class JavaDescriptorResolver {
getterDescriptor.initialize(propertyType); getterDescriptor.initialize(propertyType);
} }
if (setterDescriptor != null) { if (setterDescriptor != null) {
setterDescriptor.initialize(new ValueParameterDescriptorImpl(setterDescriptor, 0, Collections.<AnnotationDescriptor>emptyList(), "p0"/*TODO*/, false, propertyDescriptor.getOutType(), false, null)); setterDescriptor.initialize(new ValueParameterDescriptorImpl(setterDescriptor, 0, Collections.<AnnotationDescriptor>emptyList(), "p0"/*TODO*/, false, propertyDescriptor.getType(), false, null));
} }
semanticServices.getTrace().record(BindingContext.VARIABLE, anyMember.getMember().psiMember, propertyDescriptor); semanticServices.getTrace().record(BindingContext.VARIABLE, anyMember.getMember().psiMember, propertyDescriptor);
@@ -68,7 +68,7 @@ public class FunctionDescriptorUtil {
for (int i = 0, unsubstitutedValueParametersSize = unsubstitutedValueParameters.size(); i < unsubstitutedValueParametersSize; i++) { for (int i = 0, unsubstitutedValueParametersSize = unsubstitutedValueParameters.size(); i < unsubstitutedValueParametersSize; i++) {
ValueParameterDescriptor unsubstitutedValueParameter = unsubstitutedValueParameters.get(i); ValueParameterDescriptor unsubstitutedValueParameter = unsubstitutedValueParameters.get(i);
// TODO : Lazy? // 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 varargElementType = unsubstitutedValueParameter.getVarargElementType();
JetType substituteVarargElementType = varargElementType == null ? null : substitutor.substitute(varargElementType, Variance.IN_VARIANCE); JetType substituteVarargElementType = varargElementType == null ? null : substitutor.substitute(varargElementType, Variance.IN_VARIANCE);
if (substitutedType == null) return null; 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.resolve.scopes.receivers.TransientReceiver;
import org.jetbrains.jet.lang.types.*; import org.jetbrains.jet.lang.types.*;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@@ -151,7 +150,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
@Override @Override
public JetType getReturnType() { public JetType getReturnType() {
return getOutType(); return getType();
} }
public boolean isVar() { public boolean isVar() {
@@ -213,7 +212,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
List<TypeParameterDescriptor> substitutedTypeParameters = Lists.newArrayList(); List<TypeParameterDescriptor> substitutedTypeParameters = Lists.newArrayList();
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(getTypeParameters(), originalSubstitutor, substitutedDescriptor, substitutedTypeParameters); TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(getTypeParameters(), originalSubstitutor, substitutedDescriptor, substitutedTypeParameters);
JetType originalOutType = getOutType(); JetType originalOutType = getType();
JetType outType = substitutor.substitute(originalOutType, Variance.OUT_VARIANCE); JetType outType = substitutor.substitute(originalOutType, Variance.OUT_VARIANCE);
if (outType == null) { if (outType == null) {
return null; // TODO : tell the user that the property was projected out 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) { public void initialize(JetType returnType) {
this.returnType = returnType == null ? getCorrespondingProperty().getOutType() : returnType; this.returnType = returnType == null ? getCorrespondingProperty().getType() : returnType;
} }
@NotNull @NotNull
@@ -37,7 +37,7 @@ public interface ValueParameterDescriptor extends VariableDescriptor, Annotated
@Override @Override
@NotNull @NotNull
JetType getOutType(); JetType getType();
@Override @Override
ValueParameterDescriptor getOriginal(); ValueParameterDescriptor getOriginal();
@@ -123,6 +123,6 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
@NotNull @NotNull
@Override @Override
public ValueParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner) { 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 class VariableAsFunctionDescriptor extends FunctionDescriptorImpl {
public static VariableAsFunctionDescriptor create(@NotNull VariableDescriptor variableDescriptor) { public static VariableAsFunctionDescriptor create(@NotNull VariableDescriptor variableDescriptor) {
JetType outType = variableDescriptor.getOutType(); JetType outType = variableDescriptor.getType();
assert outType != null; assert outType != null;
VariableAsFunctionDescriptor result = new VariableAsFunctionDescriptor(variableDescriptor); VariableAsFunctionDescriptor result = new VariableAsFunctionDescriptor(variableDescriptor);
FunctionDescriptorUtil.initializeFromFunctionType(result, outType, variableDescriptor.getExpectedThisObject()); FunctionDescriptorUtil.initializeFromFunctionType(result, outType, variableDescriptor.getExpectedThisObject());
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.types.TypeSubstitutor;
*/ */
public interface VariableDescriptor extends CallableDescriptor { public interface VariableDescriptor extends CallableDescriptor {
@NotNull @NotNull
JetType getOutType(); JetType getType();
@Override @Override
@SuppressWarnings({"NullableProblems"}) @SuppressWarnings({"NullableProblems"})
@@ -52,7 +52,7 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorImpl i
} }
@Override @Override
public JetType getOutType() { public JetType getType() {
return outType; return outType;
} }
@@ -99,6 +99,6 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorImpl i
@Override @Override
public JetType getReturnType() { public JetType getReturnType() {
return getOutType(); return getType();
} }
} }
@@ -106,7 +106,7 @@ public class AnnotationResolver {
List<JetExpression> argumentExpressions = descriptorToArgument.getValue().getArgumentExpressions(); List<JetExpression> argumentExpressions = descriptorToArgument.getValue().getArgumentExpressions();
ValueParameterDescriptor parameterDescriptor = descriptorToArgument.getKey(); ValueParameterDescriptor parameterDescriptor = descriptorToArgument.getKey();
for (JetExpression argument : argumentExpressions) { for (JetExpression argument : argumentExpressions) {
arguments.add(resolveAnnotationArgument(argument, parameterDescriptor.getOutType())); arguments.add(resolveAnnotationArgument(argument, parameterDescriptor.getType()));
} }
} }
descriptor.setValueArguments(arguments); descriptor.setValueArguments(arguments);
@@ -468,12 +468,12 @@ public class BodyResolver {
private void resolvePropertyInitializer(JetProperty property, PropertyDescriptor propertyDescriptor, JetExpression initializer, JetScope scope) { private void resolvePropertyInitializer(JetProperty property, PropertyDescriptor propertyDescriptor, JetExpression initializer, JetScope scope) {
//JetFlowInformationProvider flowInformationProvider = context.getDescriptorResolver().computeFlowData(property, initializer); // TODO : flow JET-15 //JetFlowInformationProvider flowInformationProvider = context.getDescriptorResolver().computeFlowData(property, initializer); // TODO : flow JET-15
ExpressionTypingServices typeInferrer = context.getSemanticServices().getTypeInferrerServices(trace); 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 type = typeInferrer.getType(context.getDescriptorResolver().getPropertyDeclarationInnerScope(scope, propertyDescriptor, propertyDescriptor.getTypeParameters(), propertyDescriptor.getReceiverParameter()), initializer, expectedTypeForInitializer);
// //
// JetType expectedType = propertyDescriptor.getInType(); // JetType expectedType = propertyDescriptor.getInType();
// if (expectedType == null) { // if (expectedType == null) {
// expectedType = propertyDescriptor.getOutType(); // expectedType = propertyDescriptor.getType();
// } // }
// if (type != null && expectedType != null // if (type != null && expectedType != null
// && !context.getSemanticServices().getTypeChecker().isSubtypeOf(type, expectedType)) { // && !context.getSemanticServices().getTypeChecker().isSubtypeOf(type, expectedType)) {
@@ -528,7 +528,7 @@ public class BodyResolver {
JetParameter jetParameter = valueParameters.get(i); JetParameter jetParameter = valueParameters.get(i);
JetExpression defaultValue = jetParameter.getDefaultValue(); JetExpression defaultValue = jetParameter.getDefaultValue();
if (defaultValue != null) { if (defaultValue != null) {
typeInferrer.getType(declaringScope, defaultValue, valueParameterDescriptor.getOutType()); typeInferrer.getType(declaringScope, defaultValue, valueParameterDescriptor.getType());
} }
} }
} }
@@ -708,11 +708,11 @@ public class DescriptorResolver {
JetType type; JetType type;
JetTypeReference typeReference = parameter.getTypeReference(); JetTypeReference typeReference = parameter.getTypeReference();
if (typeReference == null) { if (typeReference == null) {
type = propertyDescriptor.getOutType(); // TODO : this maybe unknown at this point type = propertyDescriptor.getType(); // TODO : this maybe unknown at this point
} }
else { else {
type = typeResolver.resolveType(scope, typeReference); type = typeResolver.resolveType(scope, typeReference);
JetType inType = propertyDescriptor.getOutType(); JetType inType = propertyDescriptor.getType();
if (inType != null) { if (inType != null) {
if (!TypeUtils.equalTypes(type, inType)) { if (!TypeUtils.equalTypes(type, inType)) {
trace.report(WRONG_SETTER_PARAMETER_TYPE.on(setter, typeReference, inType)); trace.report(WRONG_SETTER_PARAMETER_TYPE.on(setter, typeReference, inType));
@@ -762,7 +762,7 @@ public class DescriptorResolver {
if (getter != null) { if (getter != null) {
List<AnnotationDescriptor> annotations = annotationResolver.resolveAnnotations(scope, getter.getModifierList()); List<AnnotationDescriptor> annotations = annotationResolver.resolveAnnotations(scope, getter.getModifierList());
JetType outType = propertyDescriptor.getOutType(); JetType outType = propertyDescriptor.getType();
JetType returnType = outType; JetType returnType = outType;
JetTypeReference returnTypeReference = getter.getReturnTypeReference(); JetTypeReference returnTypeReference = getter.getReturnTypeReference();
if (returnTypeReference != null) { if (returnTypeReference != null) {
@@ -782,7 +782,7 @@ public class DescriptorResolver {
} }
else { else {
getterDescriptor = createDefaultGetter(propertyDescriptor); getterDescriptor = createDefaultGetter(propertyDescriptor);
getterDescriptor.initialize(propertyDescriptor.getOutType()); getterDescriptor.initialize(propertyDescriptor.getType());
} }
return getterDescriptor; return getterDescriptor;
} }
@@ -872,7 +872,7 @@ public class DescriptorResolver {
PropertySetterDescriptor setter = createDefaultSetter(propertyDescriptor); PropertySetterDescriptor setter = createDefaultSetter(propertyDescriptor);
propertyDescriptor.initialize(getter, setter); propertyDescriptor.initialize(getter, setter);
getter.initialize(propertyDescriptor.getOutType()); getter.initialize(propertyDescriptor.getType());
trace.record(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter, propertyDescriptor); trace.record(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter, propertyDescriptor);
return propertyDescriptor; return propertyDescriptor;
@@ -83,7 +83,7 @@ public interface Importer {
return; return;
} }
if (descriptor instanceof VariableDescriptor) { if (descriptor instanceof VariableDescriptor) {
JetType type = ((VariableDescriptor) descriptor).getOutType(); JetType type = ((VariableDescriptor) descriptor).getType();
namespaceScope.importScope(type.getMemberScope()); namespaceScope.importScope(type.getMemberScope());
} }
else if (descriptor instanceof ClassDescriptor) { else if (descriptor instanceof ClassDescriptor) {
@@ -115,7 +115,7 @@ public class OverridingUtil {
parameters.add(receiverParameter.getType()); parameters.add(receiverParameter.getType());
} }
for (ValueParameterDescriptor valueParameterDescriptor : callableDescriptor.getValueParameters()) { for (ValueParameterDescriptor valueParameterDescriptor : callableDescriptor.getValueParameters()) {
parameters.add(valueParameterDescriptor.getOutType()); parameters.add(valueParameterDescriptor.getType());
} }
return parameters; return parameters;
} }
@@ -540,7 +540,7 @@ public class CallResolver {
// We'll type check the arguments later, with the inferred types expected // We'll type check the arguments later, with the inferred types expected
TemporaryBindingTrace traceForUnknown = TemporaryBindingTrace.create(temporaryTrace); TemporaryBindingTrace traceForUnknown = TemporaryBindingTrace.create(temporaryTrace);
ExpressionTypingServices temporaryServices = new ExpressionTypingServices(semanticServices, traceForUnknown); 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)) { if (type != null && !ErrorUtils.isErrorType(type)) {
constraintSystem.addSubtypingConstraint(VALUE_ARGUMENT.assertSubtyping(type, effectiveExpectedType)); constraintSystem.addSubtypingConstraint(VALUE_ARGUMENT.assertSubtyping(type, effectiveExpectedType));
} }
@@ -663,7 +663,7 @@ public class CallResolver {
private JetType getEffectiveExpectedType(ValueParameterDescriptor valueParameterDescriptor) { private JetType getEffectiveExpectedType(ValueParameterDescriptor valueParameterDescriptor) {
JetType effectiveExpectedType = valueParameterDescriptor.getVarargElementType(); JetType effectiveExpectedType = valueParameterDescriptor.getVarargElementType();
if (effectiveExpectedType == null) { if (effectiveExpectedType == null) {
effectiveExpectedType = valueParameterDescriptor.getOutType(); effectiveExpectedType = valueParameterDescriptor.getType();
} }
return effectiveExpectedType; return effectiveExpectedType;
} }
@@ -1002,7 +1002,7 @@ public class CallResolver {
for (int i = 0; i < valueParameters.size(); i++) { for (int i = 0; i < valueParameters.size(); i++) {
ValueParameterDescriptor valueParameter = valueParameters.get(i); ValueParameterDescriptor valueParameter = valueParameters.get(i);
JetType expectedType = parameterTypes.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; return true;
} }
@@ -22,8 +22,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.JetSemanticServices; import org.jetbrains.jet.lang.JetSemanticServices;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor; 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.descriptors.ValueParameterDescriptor;
import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.OverridingUtil; import org.jetbrains.jet.lang.resolve.OverridingUtil;
@@ -104,8 +102,8 @@ public class OverloadingConflictResolver {
int fSize = fParams.size(); int fSize = fParams.size();
if (fSize != gParams.size()) return false; if (fSize != gParams.size()) return false;
for (int i = 0; i < fSize; i++) { for (int i = 0; i < fSize; i++) {
JetType fParamType = fParams.get(i).getOutType(); JetType fParamType = fParams.get(i).getType();
JetType gParamType = gParams.get(i).getOutType(); JetType gParamType = gParams.get(i).getType();
if (!typeMoreSpecific(fParamType, gParamType)) { if (!typeMoreSpecific(fParamType, gParamType)) {
return false; return false;
@@ -93,7 +93,7 @@ public class TaskPrioritizers {
variable = DescriptorUtils.filterNonExtensionProperty(scope.getProperties(name)); variable = DescriptorUtils.filterNonExtensionProperty(scope.getProperties(name));
} }
if (variable != null) { if (variable != null) {
JetType outType = variable.getOutType(); JetType outType = variable.getType();
if (outType != null && JetStandardClasses.isFunctionType(outType)) { if (outType != null && JetStandardClasses.isFunctionType(outType)) {
VariableAsFunctionDescriptor functionDescriptor = VariableAsFunctionDescriptor.create(variable); VariableAsFunctionDescriptor functionDescriptor = VariableAsFunctionDescriptor.create(variable);
if ((functionDescriptor.getReceiverParameter().exists()) == receiverNeeded) { if ((functionDescriptor.getReceiverParameter().exists()) == receiverNeeded) {
@@ -234,8 +234,8 @@ public class DataFlowInfo {
// } // }
// //
// @Nullable // @Nullable
// public JetType getOutType(@NotNull VariableDescriptor variableDescriptor) { // public JetType getType(@NotNull VariableDescriptor variableDescriptor) {
// JetType outType = variableDescriptor.getOutType(); // JetType outType = variableDescriptor.getType();
// if (outType == null) return null; // if (outType == null) return null;
// if (!outType.isNullable()) return outType; // if (!outType.isNullable()) return outType;
// NullabilityFlags nullabilityFlags = nullabilityInfo.get(variableDescriptor); // NullabilityFlags nullabilityFlags = nullabilityInfo.get(variableDescriptor);
@@ -269,7 +269,7 @@ public class DataFlowInfo {
// //
// @NotNull // @NotNull
// public List<JetType> getPossibleTypesForVariable(@NotNull VariableDescriptor variableDescriptor) { // public List<JetType> getPossibleTypesForVariable(@NotNull VariableDescriptor variableDescriptor) {
// return getPossibleTypes(variableDescriptor, variableDescriptor.getOutType()); // return getPossibleTypes(variableDescriptor, variableDescriptor.getType());
// } // }
// //
// public List<JetType> getPossibleTypesForReceiver(@NotNull ReceiverDescriptor receiver) { // public List<JetType> getPossibleTypesForReceiver(@NotNull ReceiverDescriptor receiver) {
@@ -57,7 +57,7 @@ public class DataFlowValueFactory {
@NotNull @NotNull
public DataFlowValue createDataFlowValue(@NotNull VariableDescriptor variableDescriptor) { public DataFlowValue createDataFlowValue(@NotNull VariableDescriptor variableDescriptor) {
JetType type = variableDescriptor.getOutType(); JetType type = variableDescriptor.getType();
return new DataFlowValue(variableDescriptor, type, isStableVariable(variableDescriptor), getImmanentNullability(type)); return new DataFlowValue(variableDescriptor, type, isStableVariable(variableDescriptor), getImmanentNullability(type));
} }
@@ -367,7 +367,7 @@ public class JetStandardClasses {
private static List<JetType> toTypes(List<ValueParameterDescriptor> labeledEntries) { private static List<JetType> toTypes(List<ValueParameterDescriptor> labeledEntries) {
List<JetType> result = new ArrayList<JetType>(); List<JetType> result = new ArrayList<JetType>();
for (ValueParameterDescriptor entry : labeledEntries) { for (ValueParameterDescriptor entry : labeledEntries) {
result.add(entry.getOutType()); result.add(entry.getType());
} }
return result; return result;
} }
@@ -607,7 +607,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
temporaryTrace.commit(); temporaryTrace.commit();
VariableDescriptor resultingDescriptor = resolutionResult.getResultingDescriptor(); VariableDescriptor resultingDescriptor = resolutionResult.getResultingDescriptor();
checkSuper(receiver, resultingDescriptor, context.trace, selectorExpression); checkSuper(receiver, resultingDescriptor, context.trace, selectorExpression);
return resultingDescriptor.getOutType(); return resultingDescriptor.getType();
} }
if (resolutionResult.isAmbiguity() || resolutionResult.singleResult()) { if (resolutionResult.isAmbiguity() || resolutionResult.singleResult()) {
temporaryTrace.commit(); temporaryTrace.commit();
@@ -89,7 +89,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
List<JetType> parameterTypes = Lists.newArrayList(); List<JetType> parameterTypes = Lists.newArrayList();
List<ValueParameterDescriptor> valueParameters = functionDescriptor.getValueParameters(); List<ValueParameterDescriptor> valueParameters = functionDescriptor.getValueParameters();
for (ValueParameterDescriptor valueParameter : valueParameters) { for (ValueParameterDescriptor valueParameter : valueParameters) {
parameterTypes.add(valueParameter.getOutType()); parameterTypes.add(valueParameter.getType());
} }
ReceiverDescriptor receiverParameter = functionDescriptor.getReceiverParameter(); ReceiverDescriptor receiverParameter = functionDescriptor.getReceiverParameter();
JetType receiver = receiverParameter != NO_RECEIVER ? receiverParameter.getType() : null; JetType receiver = receiverParameter != NO_RECEIVER ? receiverParameter.getType() : null;
@@ -161,7 +161,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
if (functionTypeExpected && !hasDeclaredValueParameters && expectedValueParameters.size() == 1) { if (functionTypeExpected && !hasDeclaredValueParameters && expectedValueParameters.size() == 1) {
ValueParameterDescriptor valueParameterDescriptor = expectedValueParameters.get(0); ValueParameterDescriptor valueParameterDescriptor = expectedValueParameters.get(0);
ValueParameterDescriptor it = new ValueParameterDescriptorImpl( 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); valueParameterDescriptors.add(it);
context.trace.record(AUTO_CREATED_IT, it); context.trace.record(AUTO_CREATED_IT, it);
@@ -177,7 +177,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
} }
else { else {
if (expectedValueParameters != null && i < expectedValueParameters.size()) { if (expectedValueParameters != null && i < expectedValueParameters.size()) {
type = expectedValueParameters.get(i).getOutType(); type = expectedValueParameters.get(i).getType();
} }
else { else {
context.trace.report(CANNOT_INFER_PARAMETER_TYPE.on(declaredParameter)); context.trace.report(CANNOT_INFER_PARAMETER_TYPE.on(declaredParameter));
@@ -248,7 +248,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
VariableDescriptor variableDescriptor; VariableDescriptor variableDescriptor;
if (typeReference != null) { if (typeReference != null) {
variableDescriptor = context.getDescriptorResolver().resolveLocalVariableDescriptor(context.scope.getContainingDeclaration(), context.scope, loopParameter); variableDescriptor = context.getDescriptorResolver().resolveLocalVariableDescriptor(context.scope.getContainingDeclaration(), context.scope, loopParameter);
JetType actualParameterType = variableDescriptor.getOutType(); JetType actualParameterType = variableDescriptor.getType();
if (expectedParameterType != null && if (expectedParameterType != null &&
actualParameterType != null && actualParameterType != null &&
!context.semanticServices.getTypeChecker().isSubtypeOf(expectedParameterType, actualParameterType)) { !context.semanticServices.getTypeChecker().isSubtypeOf(expectedParameterType, actualParameterType)) {
@@ -377,7 +377,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
if (hasNextProperty == null) { if (hasNextProperty == null) {
return null; return null;
} else { } else {
JetType hasNextReturnType = hasNextProperty.getOutType(); JetType hasNextReturnType = hasNextProperty.getType();
if (hasNextReturnType == null) { if (hasNextReturnType == null) {
// TODO : accessibility // TODO : accessibility
context.trace.report(HAS_NEXT_MUST_BE_READABLE.on(loopRange)); context.trace.report(HAS_NEXT_MUST_BE_READABLE.on(loopRange));
@@ -401,7 +401,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
if (catchParameter != null) { if (catchParameter != null) {
VariableDescriptor variableDescriptor = context.getDescriptorResolver().resolveLocalVariableDescriptor(context.scope.getContainingDeclaration(), context.scope, catchParameter); VariableDescriptor variableDescriptor = context.getDescriptorResolver().resolveLocalVariableDescriptor(context.scope.getContainingDeclaration(), context.scope, catchParameter);
JetType throwableType = context.semanticServices.getStandardLibrary().getThrowable().getDefaultType(); 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) { if (catchBody != null) {
WritableScope catchScope = newWritableScopeImpl(context).setDebugName("Catch scope"); WritableScope catchScope = newWritableScopeImpl(context).setDebugName("Catch scope");
catchScope.addVariableDescriptor(variableDescriptor); catchScope.addVariableDescriptor(variableDescriptor);
@@ -150,7 +150,7 @@ public class ExpressionTypingUtils {
public static boolean isVariableIterable(@NotNull Project project, @NotNull VariableDescriptor variableDescriptor, @NotNull JetScope scope) { public static boolean isVariableIterable(@NotNull Project project, @NotNull VariableDescriptor variableDescriptor, @NotNull JetScope scope) {
JetExpression expression = JetPsiFactory.createExpression(project, "fake"); JetExpression expression = JetPsiFactory.createExpression(project, "fake");
ExpressionReceiver expressionReceiver = new ExpressionReceiver(expression, variableDescriptor.getOutType()); ExpressionReceiver expressionReceiver = new ExpressionReceiver(expression, variableDescriptor.getType());
ExpressionTypingContext context = ExpressionTypingContext.newContext( ExpressionTypingContext context = ExpressionTypingContext.newContext(
project, project,
JetSemanticServices.createSemanticServices(project), JetSemanticServices.createSemanticServices(project),
@@ -109,7 +109,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
VariableDescriptor propertyDescriptor = context.getDescriptorResolver().resolveLocalVariableDescriptor(scope.getContainingDeclaration(), scope, property, context.dataFlowInfo); VariableDescriptor propertyDescriptor = context.getDescriptorResolver().resolveLocalVariableDescriptor(scope.getContainingDeclaration(), scope, property, context.dataFlowInfo);
JetExpression initializer = property.getInitializer(); JetExpression initializer = property.getInitializer();
if (property.getPropertyTypeRef() != null && initializer != null) { if (property.getPropertyTypeRef() != null && initializer != null) {
JetType outType = propertyDescriptor.getOutType(); JetType outType = propertyDescriptor.getType();
JetType initializerType = facade.getType(initializer, context.replaceExpectedType(outType).replaceScope(scope)); JetType initializerType = facade.getType(initializer, context.replaceExpectedType(outType).replaceScope(scope));
} }
@@ -152,7 +152,7 @@ public class DescriptorRenderer implements Renderer {
@Override @Override
public Void visitVariableDescriptor(VariableDescriptor descriptor, StringBuilder builder) { 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); renderName(descriptor, builder);
builder.append(" : ").append(escape(typeString)); builder.append(" : ").append(escape(typeString));
return super.visitVariableDescriptor(descriptor, builder); return super.visitVariableDescriptor(descriptor, builder);
@@ -188,7 +188,7 @@ public class DescriptorRenderer implements Renderer {
String typeString = renderPropertyPrefixAndComputeTypeString( String typeString = renderPropertyPrefixAndComputeTypeString(
builder, descriptor.getTypeParameters(), builder, descriptor.getTypeParameters(),
descriptor.getReceiverParameter(), descriptor.getReceiverParameter(),
descriptor.getOutType()); descriptor.getType());
renderName(descriptor, builder); renderName(descriptor, builder);
builder.append(" : ").append(escape(typeString)); builder.append(" : ").append(escape(typeString));
return null; return null;
@@ -16,7 +16,6 @@
package org.jetbrains.jet.compiler; package org.jetbrains.jet.compiler;
import com.google.common.io.ByteStreams;
import com.google.common.io.Files; import com.google.common.io.Files;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.codegen.PropertyCodegen; import org.jetbrains.jet.codegen.PropertyCodegen;
@@ -34,7 +33,6 @@ import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor; import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
import org.jetbrains.jet.lang.descriptors.VariableDescriptor; import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.psi.JetPsiUtil;
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver; import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
import org.jetbrains.jet.lang.resolve.java.JavaNamespaceDescriptor; import org.jetbrains.jet.lang.resolve.java.JavaNamespaceDescriptor;
import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.JetScope;
@@ -282,7 +280,7 @@ class NamespaceComparator {
} }
sb.append(prop.getName()); sb.append(prop.getName());
sb.append(": "); sb.append(": ");
new Serializer(sb).serialize(prop.getOutType()); new Serializer(sb).serialize(prop.getType());
} }
public void serialize(ValueParameterDescriptor valueParameter) { public void serialize(ValueParameterDescriptor valueParameter) {
@@ -297,7 +295,7 @@ class NamespaceComparator {
if (valueParameter.getVarargElementType() != null) { if (valueParameter.getVarargElementType() != null) {
serialize(valueParameter.getVarargElementType()); serialize(valueParameter.getVarargElementType());
} else { } else {
serialize(valueParameter.getOutType()); serialize(valueParameter.getType());
} }
if (valueParameter.hasDefaultValue()) { if (valueParameter.hasDefaultValue()) {
sb.append(" = ?"); sb.append(" = ?");
@@ -142,7 +142,7 @@ public class JetResolveTest extends ExtensibleResolveTestCase {
List<ValueParameterDescriptor> unsubstitutedValueParameters = resolvedCall.getResultingDescriptor().getValueParameters(); List<ValueParameterDescriptor> unsubstitutedValueParameters = resolvedCall.getResultingDescriptor().getValueParameters();
for (int i = 0, unsubstitutedValueParametersSize = unsubstitutedValueParameters.size(); i < unsubstitutedValueParametersSize; i++) { for (int i = 0, unsubstitutedValueParametersSize = unsubstitutedValueParameters.size(); i < unsubstitutedValueParametersSize; i++) {
ValueParameterDescriptor unsubstitutedValueParameter = unsubstitutedValueParameters.get(i); ValueParameterDescriptor unsubstitutedValueParameter = unsubstitutedValueParameters.get(i);
if (unsubstitutedValueParameter.getOutType().equals(parameterType[i])) { if (unsubstitutedValueParameter.getType().equals(parameterType[i])) {
return resolvedCall.getResultingDescriptor(); return resolvedCall.getResultingDescriptor();
} }
} }
@@ -92,9 +92,9 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
else { else {
bodyBuilder.append("val "); bodyBuilder.append("val ");
} }
bodyBuilder.append(descriptor.getName()).append(": ").append(descriptor.getOutType()); bodyBuilder.append(descriptor.getName()).append(": ").append(descriptor.getType());
ImportClassHelper.addImportDirectiveIfNeeded(descriptor.getOutType(), file); ImportClassHelper.addImportDirectiveIfNeeded(descriptor.getType(), file);
String initializer = defaultInitializer(descriptor.getOutType(), JetStandardLibrary.getInstance()); String initializer = defaultInitializer(descriptor.getType(), JetStandardLibrary.getInstance());
if (initializer != null) { if (initializer != null) {
bodyBuilder.append("=").append(initializer); bodyBuilder.append("=").append(initializer);
} }
@@ -116,9 +116,9 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
first = false; first = false;
bodyBuilder.append(parameterDescriptor.getName()); bodyBuilder.append(parameterDescriptor.getName());
bodyBuilder.append(": "); bodyBuilder.append(": ");
bodyBuilder.append(parameterDescriptor.getOutType().toString()); bodyBuilder.append(parameterDescriptor.getType().toString());
ImportClassHelper.addImportDirectiveIfNeeded(parameterDescriptor.getOutType(), file); ImportClassHelper.addImportDirectiveIfNeeded(parameterDescriptor.getType(), file);
} }
bodyBuilder.append(")"); bodyBuilder.append(")");
final JetType returnType = descriptor.getReturnType(); final JetType returnType = descriptor.getReturnType();
@@ -64,7 +64,7 @@ public final class DescriptorLookupConverter {
@Override @Override
public String fun(ValueParameterDescriptor valueParameterDescriptor) { public String fun(ValueParameterDescriptor valueParameterDescriptor) {
return valueParameterDescriptor.getName() + ":" + return valueParameterDescriptor.getName() + ":" +
DescriptorRenderer.TEXT.renderType(valueParameterDescriptor.getOutType()); DescriptorRenderer.TEXT.renderType(valueParameterDescriptor.getType());
} }
}, ",") + ")"; }, ",") + ")";
@@ -78,7 +78,7 @@ public final class DescriptorLookupConverter {
} }
} }
else if (descriptor instanceof VariableDescriptor) { else if (descriptor instanceof VariableDescriptor) {
JetType outType = ((VariableDescriptor) descriptor).getOutType(); JetType outType = ((VariableDescriptor) descriptor).getType();
typeText = DescriptorRenderer.TEXT.renderType(outType); typeText = DescriptorRenderer.TEXT.renderType(outType);
} }
else if (descriptor instanceof ClassDescriptor) { else if (descriptor instanceof ClassDescriptor) {
@@ -173,7 +173,7 @@ public class JetFunctionParameterInfoHandler implements
} }
private static JetType getActualParameterType(ValueParameterDescriptor descriptor) { private static JetType getActualParameterType(ValueParameterDescriptor descriptor) {
JetType paramType = descriptor.getOutType(); JetType paramType = descriptor.getType();
if (descriptor.getVarargElementType() != null) paramType = descriptor.getVarargElementType(); if (descriptor.getVarargElementType() != null) paramType = descriptor.getVarargElementType();
return paramType; return paramType;
} }
@@ -190,7 +190,7 @@ public class JetStructureViewElement implements StructureViewTreeElement {
@Override @Override
public String fun(ValueParameterDescriptor valueParameterDescriptor) { public String fun(ValueParameterDescriptor valueParameterDescriptor) {
return valueParameterDescriptor.getName() + ":" + return valueParameterDescriptor.getName() + ":" +
DescriptorRenderer.TEXT.renderType(valueParameterDescriptor.getOutType()); DescriptorRenderer.TEXT.renderType(valueParameterDescriptor.getType());
} }
}, },
","); ",");
@@ -201,7 +201,7 @@ public class JetStructureViewElement implements StructureViewTreeElement {
textBuilder.append(":").append(DescriptorRenderer.TEXT.renderType(returnType)); textBuilder.append(":").append(DescriptorRenderer.TEXT.renderType(returnType));
} }
else if (descriptor instanceof VariableDescriptor) { else if (descriptor instanceof VariableDescriptor) {
JetType outType = ((VariableDescriptor) descriptor).getOutType(); JetType outType = ((VariableDescriptor) descriptor).getType();
textBuilder = new StringBuilder(descriptor.getName()); textBuilder = new StringBuilder(descriptor.getName());
textBuilder.append(":").append(DescriptorRenderer.TEXT.renderType(outType)); textBuilder.append(":").append(DescriptorRenderer.TEXT.renderType(outType));