if (t.hasTag(TYPEVAR) && ((TypeVar)t).isCaptured()) { inferenceContext.addVar((TypeVar)t);
if (t.hasTag(TYPEVAR) && ((TypeVar)t).isCaptured()) { inferenceContext.addVar((TypeVar)t);
/** * 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; }
public Type apply(Type t) { if (t.hasTag(TYPEVAR)) { TypeVar tv = (TypeVar)t; if (tv.isCaptured()) { return new CapturedUndetVar((CapturedType)tv, types); } else { return new UndetVar(tv, types); } } else { return t.map(this); } } };
public Type apply(Type t) { if (t.hasTag(TYPEVAR)) { TypeVar tv = (TypeVar)t; if (tv.isCaptured()) { return new CapturedUndetVar((CapturedType)tv, types); } else { return new UndetVar(tv, types); } } else { return t.map(this); } } };
/** * Get a capture variable's upper bound, returning other types unchanged. * @param t a type */ public Type cvarUpperBound(Type t) { if (t.hasTag(TYPEVAR)) { TypeVar v = (TypeVar) t.unannotatedType(); return v.isCaptured() ? cvarUpperBound(v.bound) : v; } else return t.unannotatedType(); }
/** * Get a capture variable's lower bound, returning other types unchanged. * @param t a type */ public Type cvarLowerBound(Type t) { if (t.hasTag(TYPEVAR)) { TypeVar v = (TypeVar) t.unannotatedType(); return v.isCaptured() ? cvarLowerBound(v.getLowerBound()) : v; } else return t.unannotatedType(); } // </editor-fold>
public boolean isCaptureOf(Type s, WildcardType t) { if (!s.hasTag(TYPEVAR) || !((TypeVar)s.unannotatedType()).isCaptured()) return false; return isSameWildcard(t, ((CapturedType)s.unannotatedType()).wildcard); }
public boolean isCaptureOf(Type s, WildcardType t) { if (!s.hasTag(TYPEVAR) || !((TypeVar)s.unannotatedType()).isCaptured()) return false; return isSameWildcard(t, ((CapturedType)s.unannotatedType()).wildcard); }
/** * 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; }