@Override public boolean equals(Object other) { if (other instanceof Value) { Value val = ((Value) other).deref(); if (val instanceof CompFunctionValue || val instanceof IterFunctionValue) { return false; // Play safe - we can't really tell } else if (val instanceof FunctionValue) { FunctionValue ov = (FunctionValue) val; return ov.type.equals(type) && // Param and result types same ov.body.equals(body); // Not ideal - a string comparison in fact } } return false; }