UnionType implements InferredType { @Override public boolean canHaveMember(String memberName) { return types.stream().anyMatch(t -> t.canHaveMember(memberName)); } 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 canHaveMember() { ClassSymbolImpl x = new ClassSymbolImpl("x", "x"); x.addMembers(Collections.singleton(new SymbolImpl("xxx", null))); ClassSymbolImpl y = new ClassSymbolImpl("y", "y"); ClassSymbolImpl z = new ClassSymbolImpl("z", "z"); z.addMembers(Collections.singleton(new SymbolImpl("foo", null))); assertThat(or(runtimeType(x), runtimeType(y)).canHaveMember("foo")).isFalse(); assertThat(or(runtimeType(x), runtimeType(z)).canHaveMember("foo")).isTrue(); }