allow null from CallableDescriptor.getReturnType

This commit is contained in:
Stepan Koltsov
2011-11-24 23:13:03 +04:00
parent aba6b3d6b9
commit 9ef4790976
6 changed files with 8 additions and 7 deletions
@@ -21,7 +21,9 @@ public interface CallableDescriptor extends DeclarationDescriptor {
@NotNull @NotNull
List<TypeParameterDescriptor> getTypeParameters(); List<TypeParameterDescriptor> getTypeParameters();
@NotNull /**
* Method may return null for not yet fully initialized object or if error occurred.
*/
JetType getReturnType(); JetType getReturnType();
@NotNull @NotNull
@@ -120,7 +120,6 @@ public class FunctionDescriptorImpl extends DeclarationDescriptorImpl implements
} }
@Override @Override
@NotNull
public JetType getReturnType() { public JetType getReturnType() {
return unsubstitutedReturnType; return unsubstitutedReturnType;
} }
@@ -113,7 +113,6 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
return expectedThisObject; return expectedThisObject;
} }
@NotNull
@Override @Override
public JetType getReturnType() { public JetType getReturnType() {
return getOutType(); return getOutType();
@@ -34,7 +34,6 @@ public class PropertyGetterDescriptor extends PropertyAccessorDescriptor {
return Collections.emptyList(); return Collections.emptyList();
} }
@NotNull
@Override @Override
public JetType getReturnType() { public JetType getReturnType() {
return returnType; return returnType;
@@ -84,7 +84,6 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorImpl i
return ReceiverDescriptor.NO_RECEIVER; return ReceiverDescriptor.NO_RECEIVER;
} }
@NotNull
@Override @Override
public JetType getReturnType() { public JetType getReturnType() {
return getOutType(); 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,7 +226,6 @@ 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.getReturnType()))); builder.append(" : ").append(escape(renderType(descriptor.getReturnType())));
return super.visitFunctionDescriptor(descriptor, builder); return super.visitFunctionDescriptor(descriptor, builder);
} }