remove VariableDescriptor.inType

(approved by Andrey Breslav)
This commit is contained in:
Stepan Koltsov
2011-12-30 18:45:49 +04:00
parent 4b9e4b65b4
commit 6446e83b29
18 changed files with 46 additions and 105 deletions
@@ -229,7 +229,7 @@ public abstract class CodegenContext {
pd.getName() + "$bridge$" + accessors.size() pd.getName() + "$bridge$" + accessors.size()
); );
JetType receiverType = pd.getReceiverParameter().exists() ? pd.getReceiverParameter().getType() : null; JetType receiverType = pd.getReceiverParameter().exists() ? pd.getReceiverParameter().getType() : null;
myAccessor.setType(pd.getInType(), pd.getOutType(), Collections.<TypeParameterDescriptor>emptyList(), pd.getExpectedThisObject(), receiverType); myAccessor.setType(pd.getOutType(), 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(),
@@ -672,9 +672,11 @@ public class JetTypeMapper {
@Nullable @Nullable
public JvmMethodSignature mapSetterSignature(PropertyDescriptor descriptor, OwnerKind kind) { public JvmMethodSignature mapSetterSignature(PropertyDescriptor descriptor, OwnerKind kind) {
JetType inType = descriptor.getInType(); if (!descriptor.isVar()) {
if(inType == null)
return null; return null;
}
JetType outType = descriptor.getOutType();
String name = PropertyCodegen.setterName(descriptor.getName()); String name = PropertyCodegen.setterName(descriptor.getName());
ArrayList<Type> params = new ArrayList<Type>(); ArrayList<Type> params = new ArrayList<Type>();
@@ -694,7 +696,7 @@ public class JetTypeMapper {
} }
} }
params.add(mapType(inType)); params.add(mapType(outType));
// TODO: proper generic signature // TODO: proper generic signature
return new JvmMethodSignature(new Method(name, Type.VOID_TYPE, params.toArray(new Type[params.size()])), null, null, null, null); return new JvmMethodSignature(new Method(name, Type.VOID_TYPE, params.toArray(new Type[params.size()])), null, null, null, null);
@@ -743,7 +743,7 @@ public class JavaDescriptorResolver {
i, i,
Collections.<AnnotationDescriptor>emptyList(), // TODO Collections.<AnnotationDescriptor>emptyList(), // TODO
name, name,
null, // TODO : review false,
changeNullable ? TypeUtils.makeNullableAsSpecified(outType, nullable) : outType, changeNullable ? TypeUtils.makeNullableAsSpecified(outType, nullable) : outType,
hasDefaultValue, hasDefaultValue,
varargElementType varargElementType
@@ -767,7 +767,6 @@ public class JavaDescriptorResolver {
null, null,
DescriptorUtils.getExpectedThisObjectIfNeeded(containingDeclaration), DescriptorUtils.getExpectedThisObjectIfNeeded(containingDeclaration),
field.getName(), field.getName(),
isFinal ? null : type,
type); type);
semanticServices.getTrace().record(BindingContext.VARIABLE, field, propertyDescriptor); semanticServices.getTrace().record(BindingContext.VARIABLE, field, propertyDescriptor);
fieldDescriptorCache.put(field, propertyDescriptor); fieldDescriptorCache.put(field, propertyDescriptor);
@@ -60,7 +60,7 @@ public class FunctionDescriptorUtil {
substitutedDescriptor, substitutedDescriptor,
unsubstitutedValueParameter, unsubstitutedValueParameter,
unsubstitutedValueParameter.getAnnotations(), unsubstitutedValueParameter.getAnnotations(),
unsubstitutedValueParameter.getInType() == null ? null : substitutedType, unsubstitutedValueParameter.isVar(),
substitutedType, substitutedType,
substituteVarargElementType substituteVarargElementType
)); ));
@@ -19,7 +19,7 @@ public class LocalVariableDescriptor extends VariableDescriptorImpl {
@NotNull String name, @NotNull String name,
@Nullable JetType type, @Nullable JetType type,
boolean mutable) { boolean mutable) {
super(containingDeclaration, annotations, name, mutable ? type : null, type); super(containingDeclaration, annotations, name, type);
isVar = mutable; isVar = mutable;
} }
@@ -71,23 +71,20 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
@Nullable JetType receiverType, @Nullable JetType receiverType,
@NotNull ReceiverDescriptor expectedThisObject, @NotNull ReceiverDescriptor expectedThisObject,
@NotNull String name, @NotNull String name,
@Nullable JetType inType,
@NotNull JetType outType @NotNull JetType outType
) { ) {
this(containingDeclaration, annotations, modality, visibility, isVar, name); this(containingDeclaration, annotations, modality, visibility, isVar, name);
setType(inType, outType, Collections.<TypeParameterDescriptor>emptyList(), expectedThisObject, receiverType); setType(outType, Collections.<TypeParameterDescriptor>emptyList(), expectedThisObject, receiverType);
} }
public void setType(@Nullable JetType inType, @NotNull JetType outType, @NotNull List<TypeParameterDescriptor> typeParameters, @NotNull ReceiverDescriptor expectedThisObject, @Nullable JetType receiverType) { public void setType(@NotNull JetType outType, @NotNull List<TypeParameterDescriptor> typeParameters, @NotNull ReceiverDescriptor expectedThisObject, @Nullable JetType receiverType) {
ReceiverDescriptor receiver = receiverType == null ReceiverDescriptor receiver = receiverType == null
? NO_RECEIVER ? NO_RECEIVER
: new ExtensionReceiver(this, receiverType); : new ExtensionReceiver(this, receiverType);
setType(inType, outType, typeParameters, expectedThisObject, receiver); setType(outType, typeParameters, expectedThisObject, receiver);
} }
public void setType(@Nullable JetType inType, @NotNull JetType outType, @NotNull List<TypeParameterDescriptor> typeParameters, @NotNull ReceiverDescriptor expectedThisObject, @NotNull ReceiverDescriptor receiver) { public void setType(@NotNull JetType outType, @NotNull List<TypeParameterDescriptor> typeParameters, @NotNull ReceiverDescriptor expectedThisObject, @NotNull ReceiverDescriptor receiver) {
assert !isVar || inType != null;
setInType(inType);
setOutType(outType); setOutType(outType);
this.typeParemeters = typeParameters; this.typeParemeters = typeParameters;
@@ -123,17 +120,6 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
return getOutType(); return getOutType();
} }
@Override
public JetType getInType() {
return super.getInType();
}
@Override
@NotNull
public JetType getOutType() {
return super.getOutType();
}
public boolean isVar() { public boolean isVar() {
return isVar; return isVar;
} }
@@ -170,11 +156,9 @@ 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 originalInType = getInType();
JetType inType = originalInType == null ? null : substitutor.substitute(originalInType, Variance.IN_VARIANCE);
JetType originalOutType = getOutType(); JetType originalOutType = getOutType();
JetType outType = substitutor.substitute(originalOutType, Variance.OUT_VARIANCE); JetType outType = substitutor.substitute(originalOutType, Variance.OUT_VARIANCE);
if (inType == null && 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
} }
@@ -196,7 +180,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
substitutedReceiverType = null; substitutedReceiverType = null;
} }
substitutedDescriptor.setType(inType, outType, substitutedTypeParameters, substitutedExpectedThisObject, substitutedReceiverType); substitutedDescriptor.setType(outType, substitutedTypeParameters, substitutedExpectedThisObject, substitutedReceiverType);
return substitutedDescriptor; return substitutedDescriptor;
} }
@@ -231,7 +215,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
DescriptorUtils.convertModality(modality, makeNonAbstract), visibility, isVar, DescriptorUtils.convertModality(modality, makeNonAbstract), visibility, isVar,
getName()); getName());
propertyDescriptor.setType(getInType(), getOutType(), DescriptorUtils.copyTypeParameters(propertyDescriptor, getTypeParameters()), expectedThisObject, receiver.exists() ? receiver.getType() : null); propertyDescriptor.setType(getOutType(), DescriptorUtils.copyTypeParameters(propertyDescriptor, getTypeParameters()), expectedThisObject, receiver.exists() ? receiver.getType() : null);
PropertyGetterDescriptor newGetter = getter == null ? null : new PropertyGetterDescriptor( PropertyGetterDescriptor newGetter = getter == null ? null : new PropertyGetterDescriptor(
propertyDescriptor, Lists.newArrayList(getter.getAnnotations()), propertyDescriptor, Lists.newArrayList(getter.getAnnotations()),
@@ -35,7 +35,7 @@ public class PropertySetterDescriptor extends PropertyAccessorDescriptor {
public void initializeDefault() { public void initializeDefault() {
assert parameter == null; assert parameter == null;
parameter = new ValueParameterDescriptorImpl(this, 0, Collections.<AnnotationDescriptor>emptyList(), "<>", null, getCorrespondingProperty().getReturnType(), false, null); parameter = new ValueParameterDescriptorImpl(this, 0, Collections.<AnnotationDescriptor>emptyList(), "<>", false, getCorrespondingProperty().getReturnType(), false, null);
} }
@NotNull @NotNull
@@ -24,42 +24,37 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
int index, int index,
@NotNull List<AnnotationDescriptor> annotations, @NotNull List<AnnotationDescriptor> annotations,
@NotNull String name, @NotNull String name,
@Nullable JetType inType, boolean isVar,
@NotNull JetType outType, @NotNull JetType outType,
boolean hasDefaultValue, boolean hasDefaultValue,
@Nullable JetType varargElementType) { @Nullable JetType varargElementType) {
super(containingDeclaration, annotations, name, inType, outType); super(containingDeclaration, annotations, name, outType);
this.original = this; this.original = this;
this.index = index; this.index = index;
this.hasDefaultValue = hasDefaultValue; this.hasDefaultValue = hasDefaultValue;
this.varargElementType = varargElementType; this.varargElementType = varargElementType;
this.isVar = inType != null; this.isVar = isVar;
} }
public ValueParameterDescriptorImpl( public ValueParameterDescriptorImpl(
@NotNull DeclarationDescriptor containingDeclaration, @NotNull DeclarationDescriptor containingDeclaration,
@NotNull ValueParameterDescriptor original, @NotNull ValueParameterDescriptor original,
@NotNull List<AnnotationDescriptor> annotations, @NotNull List<AnnotationDescriptor> annotations,
@Nullable JetType inType, boolean isVar,
@NotNull JetType outType, @NotNull JetType outType,
@Nullable JetType varargElementType @Nullable JetType varargElementType
) { ) {
super(containingDeclaration, annotations, original.getName(), inType, outType); super(containingDeclaration, annotations, original.getName(), outType);
this.original = original; this.original = original;
this.index = original.getIndex(); this.index = original.getIndex();
this.hasDefaultValue = original.hasDefaultValue(); this.hasDefaultValue = original.hasDefaultValue();
this.varargElementType = varargElementType; this.varargElementType = varargElementType;
this.isVar = inType != null; this.isVar = isVar;
} }
@Override @Override
public void setType(@NotNull JetType type) { public void setType(@NotNull JetType type) {
assert getOutType() == null;
setOutType(type); setOutType(type);
if (isVar) {
assert getInType() == null;
setInType(type);
}
} }
@Override @Override
@@ -107,6 +102,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(), getInType(), getOutType(), hasDefaultValue, varargElementType); return new ValueParameterDescriptorImpl(newOwner, index, Lists.newArrayList(getAnnotations()), getName(), isVar, getOutType(), hasDefaultValue, varargElementType);
} }
} }
@@ -9,18 +9,9 @@ import org.jetbrains.jet.lang.types.TypeSubstitutor;
* @author abreslav * @author abreslav
*/ */
public interface VariableDescriptor extends CallableDescriptor { public interface VariableDescriptor extends CallableDescriptor {
/** @NotNull
* @return <code>null</code> for write-only variables (i.e. properties), variable value type otherwise
*/
@Nullable
JetType getOutType(); JetType getOutType();
/**
* @return <code>null</code> for read-only variables (i.e. val's etc), or the type expected on assignment type otherwise
*/
@Nullable
JetType getInType();
@Override @Override
@SuppressWarnings({"NullableProblems"}) @SuppressWarnings({"NullableProblems"})
@NotNull @NotNull
@@ -34,11 +34,6 @@ public class VariableDescriptorBoundToReceiver implements VariableDescriptor {
return variableDescriptor.getOutType(); return variableDescriptor.getOutType();
} }
@Override
public JetType getInType() {
return variableDescriptor.getInType();
}
@NotNull @NotNull
@Override @Override
public DeclarationDescriptor getContainingDeclaration() { public DeclarationDescriptor getContainingDeclaration() {
@@ -14,19 +14,15 @@ import java.util.Set;
* @author abreslav * @author abreslav
*/ */
public abstract class VariableDescriptorImpl extends DeclarationDescriptorImpl implements VariableDescriptor { public abstract class VariableDescriptorImpl extends DeclarationDescriptorImpl implements VariableDescriptor {
private JetType inType;
private JetType outType; private JetType outType;
public VariableDescriptorImpl( public VariableDescriptorImpl(
@NotNull DeclarationDescriptor containingDeclaration, @NotNull DeclarationDescriptor containingDeclaration,
@NotNull List<AnnotationDescriptor> annotations, @NotNull List<AnnotationDescriptor> annotations,
@NotNull String name, @NotNull String name,
@Nullable JetType inType, @NotNull JetType outType) {
@Nullable JetType outType) {
super(containingDeclaration, annotations, name); super(containingDeclaration, annotations, name);
assert (inType != null) || (outType != null);
this.inType = inType;
this.outType = outType; this.outType = outType;
} }
@@ -44,16 +40,8 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorImpl i
return outType; return outType;
} }
@Override
public JetType getInType() {
return inType;
}
protected void setInType(JetType inType) {
this.inType = inType;
}
protected void setOutType(JetType outType) { protected void setOutType(JetType outType) {
assert this.outType == null;
this.outType = outType; this.outType = outType;
} }
@@ -264,7 +264,7 @@ public class DescriptorResolver {
index, index,
annotationResolver.createAnnotationStubs(valueParameter.getModifierList()), annotationResolver.createAnnotationStubs(valueParameter.getModifierList()),
JetPsiUtil.safeName(valueParameter.getName()), JetPsiUtil.safeName(valueParameter.getName()),
valueParameter.isMutable() ? variableType : null, valueParameter.isMutable(),
variableType, variableType,
valueParameter.getDefaultValue() != null, valueParameter.getDefaultValue() != null,
varargElementType varargElementType
@@ -479,7 +479,7 @@ public class DescriptorResolver {
JetPsiUtil.safeName(objectDeclaration.getName()) JetPsiUtil.safeName(objectDeclaration.getName())
); );
propertyDescriptor.setType(null, classDescriptor.getDefaultType(), Collections.<TypeParameterDescriptor>emptyList(), DescriptorUtils.getExpectedThisObjectIfNeeded(containingDeclaration), ReceiverDescriptor.NO_RECEIVER); propertyDescriptor.setType(classDescriptor.getDefaultType(), Collections.<TypeParameterDescriptor>emptyList(), DescriptorUtils.getExpectedThisObjectIfNeeded(containingDeclaration), ReceiverDescriptor.NO_RECEIVER);
propertyDescriptor.initialize(null, null); propertyDescriptor.initialize(null, null);
JetObjectDeclarationName nameAsDeclaration = objectDeclaration.getNameAsDeclaration(); JetObjectDeclarationName nameAsDeclaration = objectDeclaration.getNameAsDeclaration();
@@ -553,8 +553,7 @@ public class DescriptorResolver {
JetType type = getVariableType(propertyScope, property, DataFlowInfo.EMPTY, true); JetType type = getVariableType(propertyScope, property, DataFlowInfo.EMPTY, true);
JetType inType = isVar ? type : null; propertyDescriptor.setType(type, typeParameterDescriptors, DescriptorUtils.getExpectedThisObjectIfNeeded(containingDeclaration), receiverDescriptor);
propertyDescriptor.setType(inType, type, typeParameterDescriptors, DescriptorUtils.getExpectedThisObjectIfNeeded(containingDeclaration), receiverDescriptor);
PropertyGetterDescriptor getter = resolvePropertyGetterDescriptor(scopeWithTypeParameters, property, propertyDescriptor); PropertyGetterDescriptor getter = resolvePropertyGetterDescriptor(scopeWithTypeParameters, property, propertyDescriptor);
PropertySetterDescriptor setter = resolvePropertySetterDescriptor(scopeWithTypeParameters, property, propertyDescriptor); PropertySetterDescriptor setter = resolvePropertySetterDescriptor(scopeWithTypeParameters, property, propertyDescriptor);
@@ -686,11 +685,11 @@ public class DescriptorResolver {
JetType type; JetType type;
JetTypeReference typeReference = parameter.getTypeReference(); JetTypeReference typeReference = parameter.getTypeReference();
if (typeReference == null) { if (typeReference == null) {
type = propertyDescriptor.getInType(); // TODO : this maybe unknown at this point type = propertyDescriptor.getOutType(); // TODO : this maybe unknown at this point
} }
else { else {
type = typeResolver.resolveType(scope, typeReference); type = typeResolver.resolveType(scope, typeReference);
JetType inType = propertyDescriptor.getInType(); JetType inType = propertyDescriptor.getOutType();
if (inType != null) { if (inType != null) {
if (!TypeUtils.equalTypes(type, inType)) { if (!TypeUtils.equalTypes(type, inType)) {
// trace.getErrorHandler().genericError(typeReference.getNode(), "Setter parameter type must be equal to the type of the property, i.e. " + inType); // trace.getErrorHandler().genericError(typeReference.getNode(), "Setter parameter type must be equal to the type of the property, i.e. " + inType);
@@ -842,8 +841,7 @@ public class DescriptorResolver {
isMutable, isMutable,
name == null ? "<no name>" : name name == null ? "<no name>" : name
); );
JetType inType = isMutable ? type : null; propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(), DescriptorUtils.getExpectedThisObjectIfNeeded(classDescriptor), ReceiverDescriptor.NO_RECEIVER);
propertyDescriptor.setType(inType, type, Collections.<TypeParameterDescriptor>emptyList(), DescriptorUtils.getExpectedThisObjectIfNeeded(classDescriptor), ReceiverDescriptor.NO_RECEIVER);
PropertyGetterDescriptor getter = createDefaultGetter(propertyDescriptor); PropertyGetterDescriptor getter = createDefaultGetter(propertyDescriptor);
PropertySetterDescriptor setter = createDefaultSetter(propertyDescriptor); PropertySetterDescriptor setter = createDefaultSetter(propertyDescriptor);
@@ -116,7 +116,7 @@ public class ErrorUtils {
null, null,
ReceiverDescriptor.NO_RECEIVER, ReceiverDescriptor.NO_RECEIVER,
"<ERROR PROPERTY>", "<ERROR PROPERTY>",
ERROR_PROPERTY_TYPE, ERROR_PROPERTY_TYPE); ERROR_PROPERTY_TYPE);
private static final Set<VariableDescriptor> ERROR_PROPERTY_GROUP = Collections.singleton(ERROR_PROPERTY); private static final Set<VariableDescriptor> ERROR_PROPERTY_GROUP = Collections.singleton(ERROR_PROPERTY);
private static FunctionDescriptor createErrorFunction(List<TypeParameterDescriptor> typeParameters, List<JetType> positionedValueArgumentTypes) { private static FunctionDescriptor createErrorFunction(List<TypeParameterDescriptor> typeParameters, List<JetType> positionedValueArgumentTypes) {
@@ -165,7 +165,7 @@ public class ErrorUtils {
i, i,
Collections.<AnnotationDescriptor>emptyList(), Collections.<AnnotationDescriptor>emptyList(),
"<ERROR VALUE_PARAMETER>", "<ERROR VALUE_PARAMETER>",
ERROR_PARAMETER_TYPE, true,
ERROR_PARAMETER_TYPE, ERROR_PARAMETER_TYPE,
false, false,
null)); null));
@@ -385,7 +385,7 @@ public class JetStandardClasses {
List<ValueParameterDescriptor> valueParameters = Lists.newArrayList(); List<ValueParameterDescriptor> valueParameters = Lists.newArrayList();
for (int i = first; i <= last; i++) { for (int i = first; i <= last; i++) {
JetType parameterType = arguments.get(i).getType(); JetType parameterType = arguments.get(i).getType();
ValueParameterDescriptorImpl valueParameterDescriptor = new ValueParameterDescriptorImpl(functionDescriptor, i, Collections.<AnnotationDescriptor>emptyList(), "p" + i, null, parameterType, false, null); ValueParameterDescriptorImpl valueParameterDescriptor = new ValueParameterDescriptorImpl(functionDescriptor, i, Collections.<AnnotationDescriptor>emptyList(), "p" + i, false, parameterType, false, null);
valueParameters.add(valueParameterDescriptor); valueParameters.add(valueParameterDescriptor);
} }
return valueParameters; return valueParameters;
@@ -145,7 +145,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", valueParameterDescriptor.getInType(), valueParameterDescriptor.getOutType(), valueParameterDescriptor.hasDefaultValue(), valueParameterDescriptor.getVarargElementType() functionDescriptor, 0, Collections.<AnnotationDescriptor>emptyList(), "it", false, valueParameterDescriptor.getOutType(), valueParameterDescriptor.hasDefaultValue(), valueParameterDescriptor.getVarargElementType()
); );
valueParameterDescriptors.add(it); valueParameterDescriptors.add(it);
context.trace.record(AUTO_CREATED_IT, it); context.trace.record(AUTO_CREATED_IT, it);
@@ -136,7 +136,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(), descriptor.getInType()); String typeString = renderPropertyPrefixAndComputeTypeString(builder, Collections.<TypeParameterDescriptor>emptyList(), ReceiverDescriptor.NO_RECEIVER, descriptor.getOutType());
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);
@@ -146,26 +146,16 @@ public class DescriptorRenderer implements Renderer {
@NotNull StringBuilder builder, @NotNull StringBuilder builder,
@NotNull List<TypeParameterDescriptor> typeParameters, @NotNull List<TypeParameterDescriptor> typeParameters,
@NotNull ReceiverDescriptor receiver, @NotNull ReceiverDescriptor receiver,
@Nullable JetType outType, @Nullable JetType outType) {
@Nullable JetType inType) {
String typeString = lt() + "no type>"; String typeString = lt() + "no type>";
if (inType != null && outType != null) { if (outType != null) {
builder.append(renderKeyword("var")).append(" "); builder.append(renderKeyword("var")).append(" ");
if (inType.equals(outType)) { typeString = renderType(outType);
typeString = renderType(outType);
}
else {
typeString = "<" + renderKeyword("in") + ": " + renderType(inType) + " " + renderKeyword("out") + ": " + renderType(outType) + ">";
}
} }
else if (outType != null) { else if (outType != null) {
builder.append(renderKeyword("val")).append(" "); builder.append(renderKeyword("val")).append(" ");
typeString = renderType(outType); typeString = renderType(outType);
} }
else if (inType != null) {
builder.append(lt()).append("write-only> ");
typeString = renderType(inType);
}
renderTypeParameters(typeParameters, builder); renderTypeParameters(typeParameters, builder);
@@ -182,8 +172,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.getOutType());
descriptor.getInType());
renderName(descriptor, builder); renderName(descriptor, builder);
builder.append(" : ").append(escape(typeString)); builder.append(" : ").append(escape(typeString));
return null; return null;
@@ -7,7 +7,7 @@ var x : Int = 1 + x
val xx : Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1 + x<!> val xx : Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1 + x<!>
get() : Int = 1 get() : Int = 1
<!VAL_WITH_SETTER!>set(value : Long) {}<!> <!VAL_WITH_SETTER!>set(value : <!WRONG_SETTER_PARAMETER_TYPE!>Long<!>) {}<!>
val p : Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1<!> val p : Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1<!>
get() = 1 get() = 1
@@ -26,4 +26,4 @@ class Test() {
a = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!> a = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!>
} }
public val <!PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE!>i<!> = 1 public val <!PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE!>i<!> = 1
} }
+2 -2
View File
@@ -7,7 +7,7 @@
val xx : Int = <error>1 + x</error> val xx : Int = <error>1 + x</error>
get() : Int = 1 get() : Int = 1
<error>set(value : Long) {}</error> <error>set(value : <error>Long</error>) {}</error>
val p : Int = <error>1</error> val p : Int = <error>1</error>
get() = 1 get() = 1
@@ -25,4 +25,4 @@ class Test() {
<error>$b</error> = $a <error>$b</error> = $a
a = <error>$b</error> a = <error>$b</error>
} }
} }