package heat; import st.TypeEnum; import st.ClassInstance; /** * A simple wrapper for TypeEnum, * meant to provide all helper methods * and structures for evaluating typing. */ class TypeBundle { TypeEnum type; ClassInstance instance; protected TypeBundle(TypeEnum type, ClassInstance instance) { this.type = type; this.instance = instance; } @Override public String toString() { return String.format("%s (%s)", type, instance); } @Override public boolean equals(Object other) { /** * We can say two types are equal, as * long as they are not equal on a * type error! */ return (other instanceof TypeBundle) && this.hasChecked() && ((TypeBundle) other).type == this.type; } public boolean hasChecked() { return type != TypeEnum.ERROR; } }