com.sun.tools.javac.code.Types.makeIntersectionType()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中com.sun.tools.javac.code.Types.makeIntersectionType()方法的一些代码示例,展示了Types.makeIntersectionType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.makeIntersectionType()方法的具体详情如下:
包路径:com.sun.tools.javac.code.Types
类名称:Types
方法名:makeIntersectionType

Types.makeIntersectionType介绍

[英]A convenience wrapper for #makeIntersectionType(List); the arguments are converted to a list and passed to the other method. Note that this might cause a symbol completion. Hence, this version of makeIntersectionType may not be called during a classfile read.
[中]一个方便的#makeIntersectionType(列表)包装器;参数被转换为一个列表并传递给另一个方法。请注意,这可能会导致符号完成。因此,在类文件读取期间可能不会调用此版本的makeIntersectionType。

代码示例

代码示例来源:origin: konsoletyper/teavm-javac

/**
 * A convenience wrapper for {@link #makeIntersectionType(List)}; the
 * arguments are converted to a list and passed to the other
 * method.  Note that this might cause a symbol completion.
 * Hence, this version of makeIntersectionType may not be called
 * during a classfile read.
 */
public Type makeIntersectionType(Type bound1, Type bound2) {
  return makeIntersectionType(List.of(bound1, bound2));
}
// </editor-fold>

代码示例来源:origin: konsoletyper/teavm-javac

/** Check that classes (or interfaces) do not each define an abstract
 *  method with same name and arguments but incompatible return types.
 *  @param pos          Position to be used for error reporting.
 *  @param t1           The first argument type.
 *  @param t2           The second argument type.
 */
public boolean checkCompatibleAbstracts(DiagnosticPosition pos,
                    Type t1,
                    Type t2) {
  return checkCompatibleAbstracts(pos, t1, t2,
                  types.makeIntersectionType(t1, t2));
}

代码示例来源:origin: konsoletyper/teavm-javac

/**
 * Make an intersection type from non-empty list of types.  The list should be ordered according to
 * {@link TypeSymbol#precedes(TypeSymbol, Types)}. Note that this might cause a symbol completion.
 * Hence, this version of makeIntersectionType may not be called during a classfile read.
 *
 * @param bounds    the types from which the intersection type is formed
 */
public IntersectionClassType makeIntersectionType(List<Type> bounds) {
  return makeIntersectionType(bounds, bounds.head.tsym.isInterface());
}

代码示例来源:origin: konsoletyper/teavm-javac

private Type arraySuperType() {
    // initialized lazily to avoid problems during compiler startup
    if (arraySuperType == null) {
      synchronized (this) {
        if (arraySuperType == null) {
          // JLS 10.8: all arrays implement Cloneable and Serializable.
          arraySuperType = makeIntersectionType(List.of(syms.serializableType,
              syms.cloneableType), true);
        }
      }
    }
    return arraySuperType;
  }
// </editor-fold>

代码示例来源:origin: konsoletyper/teavm-javac

/**
 * Set the bounds field of the given type variable to reflect a (possibly multiple) list of bounds.
 * This does not cause symbol completion as an extra parameter indicates as to whether all bounds
 * are interfaces - in which case the supertype is implicitly assumed to be 'Object'.
 *
 * @param t             a type variable
 * @param bounds        the bounds, must be nonempty
 * @param allInterfaces are all bounds interface types?
 */
public void setBounds(TypeVar t, List<Type> bounds, boolean allInterfaces) {
  t.bound = bounds.tail.isEmpty() ?
      bounds.head :
      makeIntersectionType(bounds, allInterfaces);
  t.rank_field = -1;
}
// </editor-fold>

代码示例来源:origin: konsoletyper/teavm-javac

/**
 * Return the minimum type of a closure, a compound type if no
 * unique minimum exists.
 */
private Type compoundMin(List<Type> cl) {
  if (cl.isEmpty()) return syms.objectType;
  List<Type> compound = closureMin(cl);
  if (compound.isEmpty())
    return null;
  else if (compound.tail.isEmpty())
    return compound.head;
  else
    return makeIntersectionType(compound);
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

Type ct = t.makeIntersectionType(resolvedBounds.reverse());
  return (T) t.makeIntersectionType(resolvedBounds.toList());
default:
  throw new IllegalStateException("Internal error: unknown TypeHandle kind: " + kind);

代码示例来源:origin: konsoletyper/teavm-javac

@Override
public Type visitClassType(ClassType t, Void ignored) {
  if (!t.isCompound()) {
    List<Type> typarams = t.getTypeArguments();
    List<Type> typarams1 = subst(typarams);
    Type outer = t.getEnclosingType();
    Type outer1 = subst(outer);
    if (typarams1 == typarams && outer1 == outer)
      return t;
    else
      return new ClassType(outer1, typarams1, t.tsym);
  } else {
    Type st = subst(supertype(t));
    List<Type> is = subst(interfaces(t));
    if (st == supertype(t) && is == interfaces(t))
      return t;
    else
      return makeIntersectionType(is.prepend(st));
  }
}

代码示例来源:origin: konsoletyper/teavm-javac

return makeIntersectionType(bounds);

代码示例来源:origin: konsoletyper/teavm-javac

if (Type.containsAny(upperBounds, vars)) {
  TypeSymbol fresh_tvar = new TypeVariableSymbol(Flags.SYNTHETIC, uv.qtype.tsym.name, null, uv.qtype.tsym.owner);
  fresh_tvar.type = new TypeVar(fresh_tvar, types.makeIntersectionType(uv.getBounds(InferenceBound.UPPER)), null);
  todo.append(uv);
  uv.inst = fresh_tvar.type;

代码示例来源:origin: konsoletyper/teavm-javac

return bounds.head.type;
} else {
  Type owntype = types.makeIntersectionType(TreeInfo.types(bounds));

相关文章

微信公众号

最新文章

更多

Types类方法