/** * Gets the alternate types of this union type, including structural interfaces and implicit * implementations as distinct alternatesCollapsingStructuralSubtypes. * * @return The alternate types of this union type. The returned set is immutable. */ public ImmutableList<JSType> getAlternatesWithoutStructuralTyping() { if (anyMatch(JSType::isUnionType, alternatesRetainingStructuralSubtypes)) { rebuildAlternates(); } return alternatesRetainingStructuralSubtypes; }
/** * Gets the alternate types of this union type. * * @return The alternate types of this union type. The returned set is immutable. */ public ImmutableList<JSType> getAlternates() { if (anyMatch(JSType::isUnionType, alternatesRetainingStructuralSubtypes)) { rebuildAlternates(); } return alternatesCollapsingStructuralSubtypes; }
/** * Gets the alternate types of this union type. * @return The alternate types of this union type. The returned set is * immutable. */ public Collection<JSType> getAlternates() { for (JSType t : alternatesWithoutStucturalTyping) { if (t.isUnionType()) { rebuildAlternates(); break; } } return alternates; }
/** * Gets the alternate types of this union type, including structural interfaces * and implicit implementations as are distinct alternates. * @return The alternate types of this union type. The returned set is * immutable. */ public Collection<JSType> getAlternatesWithoutStructuralTyping() { for (JSType t : alternatesWithoutStucturalTyping) { if (t.isUnionType()) { rebuildAlternates(); break; } } return alternatesWithoutStucturalTyping; }
@Override JSType resolveInternal(ErrorReporter reporter) { setResolvedTypeInternal(this); // for circularly defined types. for (int i = 0; i < alternatesRetainingStructuralSubtypes.size(); i++) { JSType alternate = alternatesRetainingStructuralSubtypes.get(i); alternate.resolve(reporter); } // Ensure the union is in a normalized state. rebuildAlternates(); return this; }
@Override JSType resolveInternal(ErrorReporter t, StaticTypedScope<JSType> scope) { setResolvedTypeInternal(this); // for circularly defined types. // Just resolve the alternates, but do not update as that breaks some error // reporting cases. for (JSType alternate : alternatesWithoutStucturalTyping) { alternate.resolve(t, scope); } // Ensure the union is in a normalized state. rebuildAlternates(); return this; }