Avoid NPEs during type inference

- Since annotated primitives are now stand-alone instances,
ensure they share the supertypes for the unnanotated version,
otherwise, NPEs occur during inference.
This commit is contained in:
Juan Martín Sotuyo Dodero
2023-01-25 01:41:56 -03:00
parent 661abf024d
commit bbacf3c8b1

View File

@ -42,6 +42,11 @@ public final class JPrimitiveType implements JTypeMirror {
this.box = new BoxedPrimitive(ts, boxType, this, typeAnnots); // not erased
}
private JPrimitiveType(JPrimitiveType pType, PSet<SymAnnot> typeAnnots) {
this(pType.ts, pType.kind, pType.type, pType.box.getSymbol(), typeAnnots);
this.superTypes = pType.superTypes; // Shared instance
}
@Override
public PSet<SymAnnot> getTypeAnnotations() {
return typeAnnots;
@ -52,7 +57,7 @@ public final class JPrimitiveType implements JTypeMirror {
if (newTypeAnnots.isEmpty() && this.typeAnnots.isEmpty()) {
return this;
}
return new JPrimitiveType(ts, kind, type, box.getSymbol(), newTypeAnnots);
return new JPrimitiveType(this, newTypeAnnots);
}
@Override