/** * Eliminate the given type from the union type. (Performs a set complement operation.) Note that * this operation is not robust and only works if this is a union of the given type with some * other types that don't involve the given type. */ public ProducedType minus(ClassOrInterface ci) { if (getDeclaration().equals(ci)) { return new BottomType(getDeclaration().getUnit()).getType(); } else if (getDeclaration() instanceof UnionType) { List<ProducedType> types = new ArrayList<ProducedType>(); for (ProducedType ct : getCaseTypes()) { if (ct.getSupertype(ci) == null) { addToUnion(types, ct.minus(ci)); } } UnionType ut = new UnionType(getDeclaration().getUnit()); ut.setCaseTypes(types); return ut.getType(); } else { return this; } }
public ProducedType getNonemptySequenceType(ProducedType pt) { return pt.minus(getEmptyDeclaration()).getSupertype(getSequenceDeclaration()); }
public ProducedType getNonemptyIterableType(ProducedType pt) { return pt.minus(getEmptyDeclaration()).getSupertype(getIterableDeclaration()); }
public ProducedType getNonemptyDefiniteType(ProducedType pt) { return pt.minus(getNothingDeclaration()).minus(getEmptyDeclaration()); }