當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。