@Override public boolean isNoType() { return referencedType.isNoType(); }
@Override public final boolean isNoType() { return referencedType.isNoType(); }
private boolean isTypedef(JSType type) { return type.isNoType(); }
@Override protected boolean isSubtype(JSType that, ImplCache implicitImplCache, SubtypingMode subtypingMode) { if (JSType.isSubtypeHelper(this, that, implicitImplCache, subtypingMode)) { return true; } else { return !that.isNoType(); } }
@Override protected boolean isSubtype(JSType that, ImplCache implicitImplCache) { if (JSType.isSubtypeHelper(this, that, implicitImplCache)) { return true; } else { return !that.isNoType(); } }
@Override public boolean isBottom() { return isNoType() || isNoResolvedType() || isNoObjectType(); }
/** * @return Whether the jstype is something known to be a local value. */ private boolean isLocalValueType(JSType jstype) { Preconditions.checkNotNull(jstype); JSType subtype = jstype.getGreatestSubtype( (JSType) compiler.getTypeIRegistry().getNativeType(JSTypeNative.OBJECT_TYPE)); // If the type includes anything related to a object type, don't assume // anything about the locality of the value. return subtype.isNoType(); }
private boolean isAliasedClassOrInterface(TypedVar symbol, JSType type) { // Confusingly typedefs are constructors. However, they cannot be aliased AFAICT. if (type.isNoType()) return false; if (!type.isConstructor() && !type.isInterface()) return false; String symbolName = symbol.getName(); String typeName = type.getDisplayName(); // Turns out that for aliases the symbol and type name differ. return !symbolName.equals(typeName) || KNOWN_CLASS_ALIASES.containsKey(symbolName); }
@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); }
public final boolean isEmptyType() { return isNoType() || isNoObjectType() || isNoResolvedType() || areIdentical(this, registry.getNativeFunctionType(JSTypeNative.LEAST_FUNCTION_TYPE)); }
JSType meet(JSType that) { UnionTypeBuilder builder = UnionTypeBuilder.create(registry); for (int i = 0; i < alternatesRetainingStructuralSubtypes.size(); i++) { JSType alternate = alternatesRetainingStructuralSubtypes.get(i); if (alternate.isSubtypeOf(that)) { builder.addAlternate(alternate); } } if (that.isUnionType()) { List<JSType> thoseAlternatesWithoutStucturalTyping = that.toMaybeUnionType().alternatesRetainingStructuralSubtypes; for (int i = 0; i < thoseAlternatesWithoutStucturalTyping.size(); i++) { JSType otherAlternate = thoseAlternatesWithoutStucturalTyping.get(i); if (otherAlternate.isSubtypeOf(this)) { builder.addAlternate(otherAlternate); } } } else if (that.isSubtypeOf(this)) { builder.addAlternate(that); } JSType result = builder.build(); if (!result.isNoType()) { return result; } else if (this.isObject() && (that.isObject() && !that.isNoType())) { return getNativeType(JSTypeNative.NO_OBJECT_TYPE); } else { return getNativeType(JSTypeNative.NO_TYPE); } }
JSType meet(JSType that) { UnionTypeBuilder builder = new UnionTypeBuilder(registry); for (JSType alternate : alternatesWithoutStucturalTyping) { if (alternate.isSubtype(that)) { builder.addAlternate(alternate); } } if (that.isUnionType()) { for (JSType otherAlternate : that.toMaybeUnionType().alternatesWithoutStucturalTyping) { if (otherAlternate.isSubtype(this)) { builder.addAlternate(otherAlternate); } } } else if (that.isSubtype(this)) { builder.addAlternate(that); } JSType result = builder.build(); if (!result.isNoType()) { return result; } else if (this.isObject() && (that.isObject() && !that.isNoType())) { return getNativeType(JSTypeNative.NO_OBJECT_TYPE); } else { return getNativeType(JSTypeNative.NO_TYPE); } }
if (!type.isNoType() && !type.isUnknownType() && type.isSubtypeOf(nullOrUndefined) && !containsForwardDeclaredUnresolvedName(type)) {
if (!type.isNoType() && !type.isUnknownType() && type.isSubtype(nullOrUndefined) && !containsForwardDeclaredUnresolvedName(type)) {
private void checkPropCreation(NodeTraversal t, Node lvalue) { if (lvalue.isGetProp()) { JSType objType = getJSType(lvalue.getFirstChild()); if (!objType.isEmptyType() && !objType.isUnknownType()) { Node prop = lvalue.getLastChild(); String propName = prop.getString(); PropDefinitionKind kind = typeRegistry.canPropertyBeDefined(objType, propName); if (!kind.equals(PropDefinitionKind.KNOWN)) { if (objType.isStruct()) { report(t, prop, ILLEGAL_PROPERTY_CREATION); } else { // null checks are reported elsewhere if (!objType.isNoType() && !objType.isUnknownType() && objType.isSubtypeOf(getNativeType(NULL_VOID))) { return; } reportMissingProperty( lvalue.getFirstChild(), objType, lvalue.getSecondChild(), kind, t, true); } } } } }
Boolean castCastToHelper(JSType thisType, JSType thatType) { if (thatType.isUnknownType() || thatType.isAllType() || thatType.isNoObjectType() // TODO(johnlenz): restrict to objects || thatType.isNoType()) { return true; } else if (thisType.isRecordType() || thatType.isRecordType()) { return true; // TODO(johnlenz): are there any misuses we can catch? } else if (isInterface(thisType) || isInterface(thatType)) { return true; // TODO(johnlenz): are there any misuses we can catch? } else if (thatType.isEnumElementType()) { return thisType.visit(this, thatType.toMaybeEnumElementType().getPrimitiveType()); } else if (thatType.isUnionType()) { return canCastToUnion(thisType, thatType.toMaybeUnionType()); } else if (thatType.isFunctionType()) { return canCastToFunction(thisType, thatType.toMaybeFunctionType()); } else if (thatType.isTemplatizedType()) { // TODO(johnlenz): once the templated type work is finished, // restrict the type parameters. return thisType.visit(this, thatType.toMaybeTemplatizedType().getReferencedTypeInternal()); } return thisType.isSubtypeOf(thatType) || thatType.isSubtypeOf(thisType); }
Boolean castCastToHelper(JSType thisType, JSType thatType) { if (thatType.isUnknownType() || thatType.isAllType() || thatType.isNoObjectType() // TODO(johnlenz): restrict to objects || thatType.isNoType()) { return true; } else if (thisType.isRecordType() || thatType.isRecordType()) { return true; // TODO(johnlenz): are there any misuses we can catch? } else if (isInterface(thisType) || isInterface(thatType)) { return true; // TODO(johnlenz): are there any misuses we can catch? } else if (thatType.isEnumElementType()) { return thisType.visit(this, thatType.toMaybeEnumElementType().getPrimitiveType()); } else if (thatType.isUnionType()) { return canCastToUnion(thisType, thatType.toMaybeUnionType()); } else if (thatType.isFunctionType()) { return canCastToFunction(thisType, thatType.toMaybeFunctionType()); } else if (thatType.isTemplatizedType()) { // TODO(johnlenz): once the templated type work is finished, // restrict the type parameters. return thisType.visit(this, thatType.toMaybeTemplatizedType().getReferencedTypeInternal()); } return thisType.isSubtype(thatType) || thatType.isSubtype(thisType); }