JDR: do not crash if signature references nonexistent class

This commit is contained in:
Stepan Koltsov
2012-05-30 21:04:25 +04:00
parent 3a3cbd53d8
commit a7aeba4e48
@@ -82,6 +82,7 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
private ClassDescriptor classDescriptor; private ClassDescriptor classDescriptor;
private JetType errorType;
private boolean nullable; private boolean nullable;
private List<TypeProjection> typeArguments; private List<TypeProjection> typeArguments;
@@ -122,7 +123,8 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
} }
if (this.classDescriptor == null) { if (this.classDescriptor == null) {
throw new IllegalStateException("class not found by name: " + ourName); // TODO: wrong exception // TODO: report in to trace
this.errorType = ErrorUtils.createErrorType("class not found by name: " + ourName);
} }
this.nullable = nullable; this.nullable = nullable;
this.typeArguments = new ArrayList<TypeProjection>(); this.typeArguments = new ArrayList<TypeProjection>();
@@ -180,12 +182,21 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
@Override @Override
public void visitEnd() { public void visitEnd() {
JetType jetType = new JetTypeImpl( if ((errorType != null) == (classDescriptor != null)) {
Collections.<AnnotationDescriptor>emptyList(), throw new IllegalStateException("must initialize either errorType or classDescriptor");
classDescriptor.getTypeConstructor(), }
nullable, JetType jetType;
typeArguments, if (errorType != null) {
classDescriptor.getMemberScope(typeArguments)); jetType = errorType;
}
else {
jetType = new JetTypeImpl(
Collections.<AnnotationDescriptor>emptyList(),
classDescriptor.getTypeConstructor(),
nullable,
typeArguments,
classDescriptor.getMemberScope(typeArguments));
}
done(jetType); done(jetType);
} }