@Override public final boolean isNoResolvedType() { return referencedType.isNoResolvedType(); }
@Override public boolean isNoResolvedType() { return referencedType.isNoResolvedType(); }
public final boolean isUnresolved() { return isNoResolvedType(); }
/** Returns whether the type has undergone resolution and resolved to a "useful" type. */ public final boolean isSuccessfullyResolved() { return isResolved() && !isNoResolvedType(); }
/** Returns whether the type has undergone resolution and resolved to a "useless" type. */ public final boolean isUnsuccessfullyResolved() { return isResolved() && isNoResolvedType(); }
public final boolean isUnresolvedOrResolvedUnknown() { return isNoResolvedType() || (isNamedType() && isUnknownType()); }
@Override public boolean isBottom() { return isNoType() || isNoResolvedType() || isNoObjectType(); }
@Override StringBuilder appendTo(StringBuilder sb, boolean forAnnotations) { JSType type = this.getReferencedType(); if (!isResolved() || type.isNoResolvedType()) { return sb.append(this.reference); } else { return type.appendTo(sb, forAnnotations); } }
@Override protected boolean isSubtype(JSType that, ImplCache implicitImplCache, SubtypingMode subtypingMode) { if (JSType.isSubtypeHelper(this, that, implicitImplCache, subtypingMode)) { return true; } else { return that.isObject() && !that.isNoType() && !that.isNoResolvedType(); } }
@Override protected boolean isSubtype(JSType that, ImplCache implicitImplCache) { if (JSType.isSubtypeHelper(this, that, implicitImplCache)) { return true; } else { return that.isObject() && !that.isNoType() && !that.isNoResolvedType(); } }
public final boolean isEmptyType() { return isNoType() || isNoObjectType() || isNoResolvedType() || (registry.getNativeFunctionType( JSTypeNative.LEAST_FUNCTION_TYPE) == this); }
if (type.isNoResolvedType()) { for (int i = 0; i < alternatesList.size(); i++) { JSType alt = alternatesList.get(i); if (alt.isNoResolvedType()) { needsFiltering = true; break; for (int i = 0; i < alternatesList.size(); i++) { JSType alt = alternatesList.get(i); if (!alt.isNoResolvedType()) { builder.addAlternate(alt);
private static boolean containsForwardDeclaredUnresolvedName(JSType type) { if (type.isUnionType()) { for (JSType alt : type.toMaybeUnionType().getAlternates()) { if (containsForwardDeclaredUnresolvedName(alt)) { return true; } } } return type.isNoResolvedType(); }
public final boolean isEmptyType() { return isNoType() || isNoObjectType() || isNoResolvedType() || areIdentical(this, registry.getNativeFunctionType(JSTypeNative.LEAST_FUNCTION_TYPE)); }
private static boolean containsForwardDeclaredUnresolvedName(JSType type) { if (type.isUnionType()) { for (JSType alt : type.toMaybeUnionType().getAlternates()) { if (containsForwardDeclaredUnresolvedName(alt)) { return true; } } } return type.isNoResolvedType(); }
private boolean conforms(JSType type) { if (type.isUnionType()) { // unwrap union types which might contain unresolved type name // references for example {Foo|undefined} for (JSType part : type.toMaybeUnionType().getAlternates()) { if (!conforms(part)) { return false; } } return true; } else { return !type.isNoResolvedType(); } } }
/** * Returns a more restricted union type than {@code this} one, in which all * subtypes of {@code type} have been removed.<p> * * Examples: * <ul> * <li>{@code (number,string)} restricted by {@code number} is * {@code string}</li> * <li>{@code (null, EvalError, URIError)} restricted by * {@code Error} is {@code null}</li> * </ul> * * @param type the supertype of the types to remove from this union type */ public JSType getRestrictedUnion(JSType type) { UnionTypeBuilder restricted = UnionTypeBuilder.create(registry); for (int i = 0; i < alternatesRetainingStructuralSubtypes.size(); i++) { JSType t = alternatesRetainingStructuralSubtypes.get(i); // Keep all unknown/unresolved types. if (t.isUnknownType() || t.isNoResolvedType() || !t.isSubtypeOf(type)) { restricted.addAlternate(t); } } return restricted.build(); }
if (type.isNoResolvedType()) { boolean needsFiltering = false; for (JSType alt : unionType.getAlternates()) { if (alt.isNoResolvedType()) { needsFiltering = true; break; builder.addAlternate(type.getNativeType(JSTypeNative.NO_RESOLVED_TYPE)); for (JSType alt : unionType.getAlternates()) { if (!alt.isNoResolvedType()) { builder.addAlternate(alt);
/** * Returns a more restricted union type than {@code this} one, in which all * subtypes of {@code type} have been removed.<p> * * Examples: * <ul> * <li>{@code (number,string)} restricted by {@code number} is * {@code string}</li> * <li>{@code (null, EvalError, URIError)} restricted by * {@code Error} is {@code null}</li> * </ul> * * @param type the supertype of the types to remove from this union type */ public JSType getRestrictedUnion(JSType type) { UnionTypeBuilder restricted = new UnionTypeBuilder(registry); for (JSType t : alternatesWithoutStucturalTyping) { // Keep all unknown/unresolved types. if (t.isUnknownType() || t.isNoResolvedType() || !t.isSubtype(type)) { restricted.addAlternate(t); } } return restricted.build(); }
private ConformanceResult checkConformance( NodeTraversal t, Node n, Restriction r, boolean isCallInvocation) { TypeIRegistry registry = t.getCompiler().getTypeIRegistry(); JSType methodClassType = registry.getType(r.type); Node lhs = isCallInvocation ? n.getFirstFirstChild() : n.getFirstChild(); if (methodClassType != null && lhs.getJSType() != null) { JSType targetType = lhs.getJSType().restrictByNotNullOrUndefined(); if (targetType.isUnknownType() || targetType.isNoResolvedType() || targetType.isAllType() || targetType.isEquivalentTo( registry.getNativeType(JSTypeNative.OBJECT_TYPE))) { if (!ConformanceUtil.validateCall( compiler, n.getParent(), r.restrictedCallType, isCallInvocation)) { return ConformanceResult.POSSIBLE_VIOLATION_DUE_TO_LOOSE_TYPES; } } else if (targetType.isSubtype(methodClassType)) { if (!ConformanceUtil.validateCall( compiler, n.getParent(), r.restrictedCallType, isCallInvocation)) { return ConformanceResult.VIOLATION; } } } return ConformanceResult.CONFORMANCE; }