/** * Returns the upper bound of a type if it has one, or the type itself if not. Correctly handles * wildcards and capture variables. */ public static Type getUpperBound(Type type, Types types) { if (type.hasTag(TypeTag.WILDCARD)) { return types.wildUpperBound(type); } if (type.hasTag(TypeTag.TYPEVAR) && ((TypeVar) type).isCaptured()) { return types.cvarUpperBound(type); } if (type.getUpperBound() != null) { return type.getUpperBound(); } // concrete type, e.g. java.lang.String, or a case we haven't considered return type; }
private String getSimpleTypeName(Type typ) { if (typ.getKind() == TypeKind.TYPEVAR) return typ.getUpperBound().tsym.getSimpleName().toString(); else return typ.tsym.getSimpleName().toString(); }
public Type getUpperBound() { return qtype.getUpperBound(); } public boolean isErroneous() { return qtype.isErroneous(); }
@Override public Type getUpperBound() { return underlyingType.getUpperBound(); } @Override
public Type getUpperBound() { return qtype.getUpperBound(); } public boolean isErroneous() { return qtype.isErroneous(); }
@Override public Type getUpperBound() { return underlyingType.getUpperBound(); } @Override
public Type getUpperBound() { return qtype.getUpperBound(); } public Object clone() { DelegatedType t = (DelegatedType)super.clone(); t.qtype = (Type)qtype.clone(); return t; }
public Type getUpperBound() { return qtype.getUpperBound(); } public Object clone() { DelegatedType t = (DelegatedType)super.clone(); t.qtype = (Type)qtype.clone(); return t; }
@Override public Type getUpperBound() { if ((bound == null || bound.hasTag(NONE)) && this != tsym.type) { bound = tsym.type.getUpperBound(); } return bound; }
@Override public Type getUpperBound() { if ((bound == null || bound.hasTag(NONE)) && this != tsym.type) { bound = tsym.type.getUpperBound(); } return bound; }
public Type apply(Type t) { return new TypeVar(t.tsym, t.getUpperBound()); } };
public Type apply(Type t) { while (t.hasTag(TYPEVAR)) { t = t.getUpperBound(); } return elemtype(t); } };
void attribBounds(List<JCTypeParameter> typarams) { for (JCTypeParameter typaram : typarams) { Type bound = typaram.type.getUpperBound(); if (bound != null && bound.tsym instanceof ClassSymbol) { ClassSymbol c = (ClassSymbol)bound.tsym; if ((c.flags_field & COMPOUND) != 0) { assert (c.flags_field & UNATTRIBUTED) != 0 : c; attribClass(typaram.pos(), c); } } } }
void attribBounds(List<JCTypeParameter> typarams) { for (JCTypeParameter typaram : typarams) { Type bound = typaram.type.getUpperBound(); if (bound != null && bound.tsym instanceof ClassSymbol) { ClassSymbol c = (ClassSymbol)bound.tsym; if ((c.flags_field & COMPOUND) != 0) { assert (c.flags_field & UNATTRIBUTED) != 0 : c; attribClass(typaram.pos(), c); } } } }
public Type apply(Type t) { return new TypeVar(t.tsym, t.getUpperBound(), t.getLowerBound()); } };
public Type apply(Type t) { return new TypeVar(t.tsym, t.getUpperBound(), t.getLowerBound()); } };
public Type apply(Type t) { return new TypeVar(t.tsym, t.getUpperBound(), t.getLowerBound()); } };
private Type relaxBound(Type t) { if (t.hasTag(TYPEVAR)) { while (t.hasTag(TYPEVAR)) t = t.getUpperBound(); t = rewriteQuantifiers(t, true, true); } return t; } // </editor-fold>
private Type relaxBound(Type t) { if (t.hasTag(TYPEVAR)) { while (t.hasTag(TYPEVAR)) t = t.getUpperBound(); t = rewriteQuantifiers(t, true, true); } return t; } // </editor-fold>
/** * Does t have the same bounds for quantified variables as s? */ boolean hasSameBounds(ForAll t, ForAll s) { List<Type> l1 = t.tvars; List<Type> l2 = s.tvars; while (l1.nonEmpty() && l2.nonEmpty() && isSameType(l1.head.getUpperBound(), subst(l2.head.getUpperBound(), s.tvars, t.tvars))) { l1 = l1.tail; l2 = l2.tail; } return l1.isEmpty() && l2.isEmpty(); } // </editor-fold>