MoreTypes.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:android-auto-mapper 作者:
@Override
public Boolean visitTypeVariable(TypeVariable a, EqualVisitorParam p) {
    if (p.type.getKind().equals(TYPEVAR)) {
        TypeVariable b = (TypeVariable) p.type;
        TypeParameterElement aElement = (TypeParameterElement) a.asElement();
        TypeParameterElement bElement = (TypeParameterElement) b.asElement();
        Set<ComparedElements> newVisiting = visitingSetPlus(p.visiting, aElement, bElement);
        if (newVisiting.equals(p.visiting)) {
            // We're already visiting this pair of elements.
            // This can happen with our friend Eclipse when looking at <T extends Comparable<T>>.
            // It incorrectly reports the upper bound of T as T itself.
            return true;
        }
        // We use aElement.getBounds() instead of a.getUpperBound() to avoid having to deal with
        // the different way intersection types (like <T extends Number & Comparable<T>>) are
        // represented before and after Java 8. We do have an issue that this code may consider
        // that <T extends Foo & Bar> is different from <T extends Bar & Foo>, but it's very
        // hard to avoid that, and not likely to be much of a problem in practice.
        return equalLists(aElement.getBounds(), bElement.getBounds(), newVisiting)
                && equal(a.getLowerBound(), b.getLowerBound(), newVisiting)
                && a.asElement().getSimpleName().equals(b.asElement().getSimpleName());
    }
    return false;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号