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