@Override public boolean equals(Object object) { if (object instanceof TypeMismatch) { TypeMismatch that = (TypeMismatch) object; return (that.typeA.isEquivalentTo(this.typeA) && that.typeB.isEquivalentTo(this.typeB)) || (that.typeB.isEquivalentTo(this.typeA) && that.typeA.isEquivalentTo(this.typeB)); } return false; }
public static boolean isEquivalent(JSType typeA, JSType typeB) { return (typeA == null || typeB == null) ? typeA == typeB : typeA.isEquivalentTo(typeB); }
/** Checks if two types are equivalent. */ public final boolean isEquivalentTo(@Nullable JSType that) { return isEquivalentTo(that, false); }
@Override public boolean equals(@Nullable Object jsType) { return (jsType instanceof JSType) && isEquivalentTo((JSType) jsType); }
public static final boolean isEquivalent(@Nullable JSType typeA, @Nullable JSType typeB) { return (typeA == null) ? (typeB == null) : typeA.isEquivalentTo(typeB); }
private boolean isNonNullable(JSType type) { // TODO(lpino): Verify that nonNullableTypeNames is correct for (String s : nonNullableTypeNames) { JSType that = getType(s); if (that != null && type.isEquivalentTo(that)) { return true; } } return false; }
@Override protected boolean isSubtype(JSType that, ImplCache implicitImplCache, SubtypingMode subtypingMode) { return that.isEquivalentTo(getNativeType(JSTypeNative.OBJECT_TYPE)) || that.isEquivalentTo(getNativeType(JSTypeNative.OBJECT_PROTOTYPE)) || JSType.isSubtypeHelper(this, that, implicitImplCache, subtypingMode); }
@Override protected boolean isSubtype(JSType that, ImplCache implicitImplCache) { return that.isEquivalentTo(getNativeType(JSTypeNative.OBJECT_TYPE)) || that.isEquivalentTo(getNativeType(JSTypeNative.OBJECT_PROTOTYPE)) || JSType.isSubtypeHelper(this, that, implicitImplCache); }
/** * A generic implementation meant to be used as a helper for common getLeastSupertype * implementations. */ @SuppressWarnings("AmbiguousMethodReference") static JSType getLeastSupertype(JSType thisType, JSType thatType) { boolean areEquivalent = thisType.isEquivalentTo(thatType); return areEquivalent ? thisType : filterNoResolvedType( thisType.registry.createUnionType(thisType, thatType)); }
/** * A generic implementation meant to be used as a helper for common * getLeastSupertype implementations. */ static JSType getLeastSupertype(JSType thisType, JSType thatType) { boolean areEquivalent = thisType.isEquivalentTo(thatType); return areEquivalent ? thisType : filterNoResolvedType( thisType.registry.createUnionType(thisType, thatType)); }
protected boolean isNativeObjectType(Node n) { JSType type = n.getJSType().restrictByNotNullOrUndefined(); return type.isEquivalentTo(nativeObjectType); }
protected boolean isNativeObjectType(Node n) { JSType type = n.getJSType().restrictByNotNullOrUndefined(); return type.isEquivalentTo(nativeObjectType); }
@Override public JSType caseEnumElementType(EnumElementType enumElementType) { JSType type = enumElementType.getPrimitiveType().visit(this); if (type != null && enumElementType.getPrimitiveType().isEquivalentTo(type)) { return enumElementType; } else { return type; } }
@Override public JSType caseEnumElementType(EnumElementType enumElementType) { JSType type = enumElementType.getPrimitiveType().visit(this); if (type != null && enumElementType.getPrimitiveType().isEquivalentTo(type)) { return enumElementType; } else { return type; } }
@Override public JSType caseEnumElementType(EnumElementType enumElementType) { JSType type = enumElementType.getPrimitiveType().visit(this); if (type != null && enumElementType.getPrimitiveType().isEquivalentTo(type)) { return enumElementType; } else { return type; } }
@Override public JSType caseEnumElementType(EnumElementType enumElementType) { JSType type = enumElementType.getPrimitiveType().visit(this); if (type != null && enumElementType.getPrimitiveType().isEquivalentTo(type)) { return enumElementType; } else { return type; } }
boolean wrapsSameRawType(JSType that) { return that.isTemplatizedType() && this.getReferencedTypeInternal() .isEquivalentTo( that.toMaybeTemplatizedType().getReferencedTypeInternal()); }
private static boolean areTypesEquivalentIgnoringGenerics(JSType a, JSType b) { boolean equivalent = a.isEquivalentTo(b); if (equivalent) { return true; } if (a.isTemplatizedType()) { return a.toMaybeTemplatizedType().getReferencedType().isEquivalentTo(b); } return false; }
boolean wrapsSameRawType(JSType that) { return that.isTemplatizedType() && this.getReferencedTypeInternal() .isEquivalentTo( that.toMaybeTemplatizedType().getReferencedTypeInternal()); }
@Override public boolean matches(Node node, NodeMetadata metadata) { JSType providedJsType = getJsType(metadata, type); if (providedJsType == null) { return false; } providedJsType = providedJsType.restrictByNotNullOrUndefined(); JSType jsType = node.getJSType(); return jsType != null && jsType.isEnumType() && providedJsType.isEquivalentTo( jsType.toMaybeEnumType().getElementsType().getPrimitiveType()); } };