UnionType implements InferredType { @Override public boolean isIdentityComparableWith(InferredType other) { return types.stream().anyMatch(t -> t.isIdentityComparableWith(other)); } private  UnionType(Set<InferredType> types); static InferredType or(InferredType type1, InferredType type2); @Override boolean isIdentityComparableWith(InferredType other); @Override boolean canHaveMember(String memberName); @Override boolean declaresMember(String memberName); @Override Optional<Symbol> resolveMember(String memberName); @Override Optional<Symbol> resolveDeclaredMember(String memberName); @Override boolean canOnlyBe(String typeName); @Override boolean canBeOrExtend(String typeName); @Override boolean isCompatibleWith(InferredType other); boolean mustBeOrExtend(String fullyQualifiedName); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void isIdentityComparableWith() { assertThat(or(a, b).isIdentityComparableWith(anyType())).isTrue(); assertThat(or(a, b).isIdentityComparableWith(a)).isTrue(); assertThat(or(a, b).isIdentityComparableWith(b)).isTrue(); assertThat(or(a, b).isIdentityComparableWith(c)).isFalse(); assertThat(or(a, b).isIdentityComparableWith(or(b, a))).isTrue(); assertThat(or(a, b).isIdentityComparableWith(or(c, d))).isFalse(); }