fix DescriptionRenderer failure if FunctionDescriptor.getReturnType returns null

This commit is contained in:
Stepan Koltsov
2011-11-23 17:25:36 +04:00
parent 8222011874
commit fed075b0ca
7 changed files with 38 additions and 3 deletions
@@ -1,6 +1,7 @@
package org.jetbrains.jet.lang.descriptors;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeSubstitutor;
@@ -24,6 +25,9 @@ public interface CallableDescriptor extends DeclarationDescriptor {
@NotNull
JetType getReturnType();
@Nullable
JetType getReturnTypeSafe();
@NotNull
@Override
CallableDescriptor getOriginal();
@@ -125,6 +125,12 @@ public class FunctionDescriptorImpl extends DeclarationDescriptorImpl implements
return unsubstitutedReturnType;
}
@Override
@Nullable
public JetType getReturnTypeSafe() {
return unsubstitutedReturnType;
}
@NotNull
@Override
public FunctionDescriptor getOriginal() {
@@ -118,6 +118,11 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
return getOutType();
}
@Override
@Nullable
public JetType getReturnTypeSafe() {
return getOutType();
}
public boolean isVar() {
return isVar;
@@ -45,6 +45,12 @@ public class PropertyGetterDescriptor extends PropertyAccessorDescriptor {
return returnType;
}
@Override
@Nullable
public JetType getReturnTypeSafe() {
return returnType;
}
@Override
public <R, D> R accept(DeclarationDescriptorVisitor<R, D> visitor, D data) {
return visitor.visitPropertyGetterDescriptor(this, data);
@@ -53,6 +53,11 @@ public class PropertySetterDescriptor extends PropertyAccessorDescriptor {
return JetStandardClasses.getUnitType();
}
@Override
public JetType getReturnTypeSafe() {
return getReturnType();
}
@Override
public <R, D> R accept(DeclarationDescriptorVisitor<R, D> visitor, D data) {
return visitor.visitPropertySetterDescriptor(this, data);
@@ -89,4 +89,10 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorImpl i
public JetType getReturnType() {
return getOutType();
}
@Override
@Nullable
public JetType getReturnTypeSafe() {
return getOutType();
}
}
@@ -73,7 +73,11 @@ public class DescriptorRenderer implements Renderer {
}
public String renderType(JetType type) {
return escape(type.toString());
if (type == null) {
return escape("<?>");
} else {
return escape(type.toString());
}
}
protected String escape(String s) {
@@ -222,8 +226,7 @@ public class DescriptorRenderer implements Renderer {
renderName(descriptor, builder);
renderValueParameters(descriptor, builder);
// TODO: getReturnType may be uninitialized and throw IllegalStateException // stepan.koltsov@ 2011-11-21
builder.append(" : ").append(escape(renderType(descriptor.getReturnType())));
builder.append(" : ").append(escape(renderType(descriptor.getReturnTypeSafe())));
return super.visitFunctionDescriptor(descriptor, builder);
}