当前位置: 首页>>代码示例>>Java>>正文


Java List.diff方法代码示例

本文整理汇总了Java中com.sun.tools.javac.util.List.diff方法的典型用法代码示例。如果您正苦于以下问题:Java List.diff方法的具体用法?Java List.diff怎么用?Java List.diff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.tools.javac.util.List的用法示例。


在下文中一共展示了List.diff方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isEquiv

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
boolean isEquiv(UndetVar from, Type t, InferenceBound boundKind) {
    UndetVar uv = (UndetVar)asUndetVar(t);
    for (InferenceBound ib : InferenceBound.values()) {
        List<Type> b1 = from.getBounds(ib);
        if (ib == boundKind) {
            b1 = b1.diff(List.of(t));
        }
        List<Type> b2 = uv.getBounds(ib);
        if (ib == boundKind.complement()) {
            b2 = b2.diff(List.of(from.qtype));
        }
        if (!b1.containsAll(b2) || !b2.containsAll(b1)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:InferenceContext.java

示例2: checkExConstraints

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
boolean checkExConstraints(
        List<Type> thrownByFuncExpr,
        List<Type> thrownAtFuncType,
        InferenceContext inferenceContext) {
    /** 18.2.5: Otherwise, let E1, ..., En be the types in the function type's throws clause that
     *  are not proper types
     */
    List<Type> nonProperList = thrownAtFuncType.stream()
            .filter(e -> inferenceContext.free(e)).collect(List.collector());
    List<Type> properList = thrownAtFuncType.diff(nonProperList);

    /** Let X1,...,Xm be the checked exception types that the lambda body can throw or
     *  in the throws clause of the invocation type of the method reference's compile-time
     *  declaration
     */
    List<Type> checkedList = thrownByFuncExpr.stream()
            .filter(e -> chk.isChecked(e)).collect(List.collector());

    /** If n = 0 (the function type's throws clause consists only of proper types), then
     *  if there exists some i (1 <= i <= m) such that Xi is not a subtype of any proper type
     *  in the throws clause, the constraint reduces to false; otherwise, the constraint
     *  reduces to true
     */
    ListBuffer<Type> uncaughtByProperTypes = new ListBuffer<>();
    for (Type checked : checkedList) {
        boolean isSubtype = false;
        for (Type proper : properList) {
            if (types.isSubtype(checked, proper)) {
                isSubtype = true;
                break;
            }
        }
        if (!isSubtype) {
            uncaughtByProperTypes.add(checked);
        }
    }

    if (nonProperList.isEmpty() && !uncaughtByProperTypes.isEmpty()) {
        return false;
    }

    /** If n > 0, the constraint reduces to a set of subtyping constraints:
     *  for all i (1 <= i <= m), if Xi is not a subtype of any proper type in the
     *  throws clause, then the constraints include, for all j (1 <= j <= n), <Xi <: Ej>
     */
    List<Type> nonProperAsUndet = inferenceContext.asUndetVars(nonProperList);
    uncaughtByProperTypes.forEach(checkedEx -> {
        nonProperAsUndet.forEach(nonProper -> {
            types.isSubtype(checkedEx, nonProper);
        });
    });

    /** In addition, for all j (1 <= j <= n), the constraint reduces to the bound throws Ej
     */
    nonProperAsUndet.stream()
            .filter(t -> t.hasTag(UNDETVAR))
            .forEach(t -> ((UndetVar)t).setThrow());
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:60,代码来源:Attr.java

示例3: min

import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
InferenceContext min(List<Type> roots, boolean shouldSolve, Warner warn) {
    if (roots.length() == inferencevars.length()) {
        return this;
    }
    ReachabilityVisitor rv = new ReachabilityVisitor();
    rv.scan(roots);
    if (rv.min.size() == inferencevars.length()) {
        return this;
    }

    List<Type> minVars = List.from(rv.min);
    List<Type> redundantVars = inferencevars.diff(minVars);

    //compute new undet variables (bounds associated to redundant variables are dropped)
    ListBuffer<Type> minUndetVars = new ListBuffer<>();
    for (Type minVar : minVars) {
        UndetVar uv = (UndetVar)asUndetVar(minVar);
        Assert.check(uv.incorporationActions.isEmpty());
        UndetVar uv2 = uv.dup(types);
        for (InferenceBound ib : InferenceBound.values()) {
            List<Type> newBounds = uv.getBounds(ib).stream()
                    .filter(b -> !redundantVars.contains(b))
                    .collect(List.collector());
            uv2.setBounds(ib, newBounds);
        }
        minUndetVars.add(uv2);
    }

    //compute new minimal inference context
    InferenceContext minContext = new InferenceContext(infer, minVars, minUndetVars.toList());
    for (Type t : minContext.inferencevars) {
        //add listener that forwards notifications to original context
        minContext.addFreeTypeListener(List.of(t), (inferenceContext) -> {
            ((UndetVar)asUndetVar(t)).setInst(inferenceContext.asInstType(t));
            infer.doIncorporation(inferenceContext, warn);
            solve(List.from(rv.minMap.get(t)), warn);
            notifyChange();
        });
    }
    if (shouldSolve) {
        //solve definitively unreachable variables
        List<Type> unreachableVars = redundantVars.diff(List.from(rv.equiv));
        minContext.addFreeTypeListener(minVars, (inferenceContext) -> {
            solve(unreachableVars, warn);
            notifyChange();
        });
    }
    return minContext;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:50,代码来源:InferenceContext.java


注:本文中的com.sun.tools.javac.util.List.diff方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。