本文整理了Java中com.sun.tools.javac.code.Types.makeCompoundType()
方法的一些代码示例,展示了Types.makeCompoundType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.makeCompoundType()
方法的具体详情如下:
包路径:com.sun.tools.javac.code.Types
类名称:Types
方法名:makeCompoundType
[英]A convenience wrapper for #makeCompoundType(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 makeCompoundType may not be called during a classfile read.
[中]#makeCompoundType(列表)的方便包装器;参数被转换为一个列表并传递给另一个方法。请注意,这可能会导致符号完成。因此,在类文件读取期间可能不会调用此版本的MakeComoundType。
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
/**
* A convenience wrapper for {@link #makeCompoundType(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 makeCompoundType may not be called
* during a classfile read.
*/
public Type makeCompoundType(Type bound1, Type bound2) {
return makeCompoundType(List.of(bound1, bound2));
}
// </editor-fold>
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-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.makeCompoundType(t1, t2));
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/**
* A convenience wrapper for {@link #makeCompoundType(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 makeCompoundType may not be called
* during a classfile read.
*/
public Type makeCompoundType(Type bound1, Type bound2) {
return makeCompoundType(List.of(bound1, bound2));
}
// </editor-fold>
代码示例来源:origin: sc.fiji/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.makeCompoundType(t1, t2));
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/**
* Make a compound type from non-empty list of types
*
* @param bounds the types from which the compound type is formed
* @param supertype is objectType if all bounds are interfaces,
* null otherwise.
*/
public Type makeCompoundType(List<Type> bounds) {
return makeCompoundType(bounds, bounds.head.tsym.isInterface());
}
public Type makeCompoundType(List<Type> bounds, boolean allInterfaces) {
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-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.makeCompoundType(t1, t2));
}
代码示例来源:origin: sc.fiji/javac
/**
* A convenience wrapper for {@link #makeCompoundType(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 makeCompoundType may not be called
* during a classfile read.
*/
public Type makeCompoundType(Type bound1, Type bound2) {
return makeCompoundType(List.of(bound1, bound2));
}
// </editor-fold>
代码示例来源:origin: sc.fiji/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 = makeCompoundType(List.of(syms.serializableType,
syms.cloneableType),
syms.objectType);
}
}
}
return arraySuperType;
}
// </editor-fold>
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-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 = makeCompoundType(List.of(syms.serializableType,
syms.cloneableType), true);
}
}
}
return arraySuperType;
}
// </editor-fold>
代码示例来源:origin: sc.fiji/javac
/**
* Set the bounds field of the given type variable to reflect a
* (possibly multiple) list of bounds.
* @param t a type variable
* @param bounds the bounds, must be nonempty
* @param supertype is objectType if all bounds are interfaces,
* null otherwise.
*/
public void setBounds(TypeVar t, List<Type> bounds, Type supertype) {
if (bounds.tail.isEmpty())
t.bound = bounds.head;
else
t.bound = makeCompoundType(bounds, supertype);
t.rank_field = -1;
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
/**
* Set the bounds field of the given type variable to reflect a
* (possibly multiple) list of bounds.
* @param t a type variable
* @param bounds the bounds, must be nonempty
* @param supertype is objectType if all bounds are interfaces,
* null otherwise.
*/
public void setBounds(TypeVar t, List<Type> bounds, Type supertype) {
if (bounds.tail.isEmpty())
t.bound = bounds.head;
else
t.bound = makeCompoundType(bounds, supertype);
t.rank_field = -1;
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-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 = makeCompoundType(List.of(syms.serializableType,
syms.cloneableType),
syms.objectType);
}
}
}
return arraySuperType;
}
// </editor-fold>
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/**
* Same as {@link #setBounds(Type.TypeVar,List,Type)}, except that
* third parameter is computed directly, as follows: if all
* all bounds are interface types, the computed supertype is Object,
* otherwise the supertype is simply left null (in this case, the supertype
* is assumed to be the head of the bound list passed as second argument).
* Note that this check might cause a symbol completion. Hence, this version of
* setBounds may not be called during a classfile read.
*/
public void setBounds(TypeVar t, List<Type> bounds, boolean allInterfaces) {
t.bound = bounds.tail.isEmpty() ?
bounds.head :
makeCompoundType(bounds, allInterfaces);
t.rank_field = -1;
}
// </editor-fold>
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
/**
* Same as {@link #makeCompoundType(List,Type)}, except that the
* second parameter is computed directly. Note that this might
* cause a symbol completion. Hence, this version of
* makeCompoundType may not be called during a classfile read.
*/
public Type makeCompoundType(List<Type> bounds) {
Type supertype = (bounds.head.tsym.flags() & INTERFACE) != 0 ?
supertype(bounds.head) : null;
return makeCompoundType(bounds, supertype);
}
代码示例来源:origin: sc.fiji/javac
/**
* Same as {@link #makeCompoundType(List,Type)}, except that the
* second parameter is computed directly. Note that this might
* cause a symbol completion. Hence, this version of
* makeCompoundType may not be called during a classfile read.
*/
public Type makeCompoundType(List<Type> bounds) {
Type supertype = (bounds.head.tsym.flags() & INTERFACE) != 0 ?
supertype(bounds.head) : null;
return makeCompoundType(bounds, supertype);
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-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 makeCompoundType(compound);
}
代码示例来源:origin: sc.fiji/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 makeCompoundType(compound);
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-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 makeCompoundType(compound);
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-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 = upperBounds(subst(interfaces(t)));
if (st == supertype(t) && is == interfaces(t))
return t;
else
return makeCompoundType(is.prepend(st));
}
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-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 = upperBounds(subst(interfaces(t)));
if (st == supertype(t) && is == interfaces(t))
return t;
else
return makeCompoundType(is.prepend(st));
}
}
内容来源于网络,如有侵权,请联系作者删除!