本文整理了Java中com.sun.tools.javac.code.Types.boxedClass()
方法的一些代码示例,展示了Types.boxedClass()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.boxedClass()
方法的具体详情如下:
包路径:com.sun.tools.javac.code.Types
类名称:Types
方法名:boxedClass
[英]Return the class that boxes the given primitive.
[中]返回装箱给定原语的类。
代码示例来源:origin: google/error-prone
@Override
public Description matchNewClass(NewClassTree tree, VisitorState state) {
Symbol sym = ASTHelpers.getSymbol(tree.getIdentifier());
if (sym == null) {
return NO_MATCH;
}
Types types = state.getTypes();
Symtab symtab = state.getSymtab();
// TODO(cushon): consider handling String also
if (sym.equals(types.boxedClass(symtab.byteType))
|| sym.equals(types.boxedClass(symtab.charType))
|| sym.equals(types.boxedClass(symtab.shortType))
|| sym.equals(types.boxedClass(symtab.intType))
|| sym.equals(types.boxedClass(symtab.longType))
|| sym.equals(types.boxedClass(symtab.doubleType))
|| sym.equals(types.boxedClass(symtab.floatType))
|| sym.equals(types.boxedClass(symtab.booleanType))) {
return describeMatch(tree, buildFix(tree, state));
}
return NO_MATCH;
}
代码示例来源:origin: google/error-prone
private DoubleAndFloatStatus doubleAndFloatStatus(
VisitorState state, Type recieverType, Type argType) {
Types types = state.getTypes();
if (!types.isSameType(recieverType, state.getSymtab().floatType)) {
return DoubleAndFloatStatus.NONE;
}
if (types.isSameType(argType, types.boxedClass(state.getSymtab().doubleType).type)) {
return DoubleAndFloatStatus.BOXED_DOUBLE_INTO_FLOAT;
}
if (types.isSameType(argType, state.getSymtab().doubleType)) {
return DoubleAndFloatStatus.PRIMITIVE_DOUBLE_INTO_FLOAT;
}
return DoubleAndFloatStatus.NONE;
}
代码示例来源:origin: konsoletyper/teavm-javac
public TypeElement boxedClass(PrimitiveType p) {
return types.boxedClass((Type) p);
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
public TypeElement boxedClass(PrimitiveType p) {
return types.boxedClass((Type) p);
}
代码示例来源:origin: sc.fiji/javac
public TypeElement boxedClass(PrimitiveType p) {
return types.boxedClass((Type) p);
}
代码示例来源:origin: konsoletyper/teavm-javac
/**
* Return the boxed type if 't' is primitive, otherwise return 't' itself.
*/
public Type boxedTypeOrType(Type t) {
return t.isPrimitive() ?
boxedClass(t).type :
t;
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
/** Box up a single primitive expression. */
JCExpression boxPrimitive(JCExpression tree) {
return boxPrimitive(tree, types.boxedClass(tree.type).type);
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/**
* Return the boxed type if 't' is primitive, otherwise return 't' itself.
*/
public Type boxedTypeOrType(Type t) {
return t.isPrimitive() ?
boxedClass(t).type :
t;
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/** Box up a single primitive expression. */
JCExpression boxPrimitive(JCExpression tree) {
return boxPrimitive(tree, types.boxedClass(tree.type).type);
}
代码示例来源:origin: sc.fiji/javac
/** Box up a single primitive expression. */
JCExpression boxPrimitive(JCExpression tree) {
return boxPrimitive(tree, types.boxedClass(tree.type).type);
}
代码示例来源:origin: konsoletyper/teavm-javac
/** Box up a single primitive expression. */
JCExpression boxPrimitive(JCExpression tree) {
return boxPrimitive(tree, types.boxedClass(tree.type).type);
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
public Type apply(Type t) {
t = types.erasure(super.apply(t));
if (t.hasTag(BOT))
// nulls type as the marker type Null (which has no instances)
// infer as java.lang.Void for now
t = types.boxedClass(syms.voidType).type;
return t;
}
}
代码示例来源:origin: konsoletyper/teavm-javac
public Type apply(Type t) {
t = types.erasure(super.apply(t));
if (t.hasTag(BOT))
// nulls type as the marker type Null (which has no instances)
// infer as java.lang.Void for now
t = types.boxedClass(syms.voidType).type;
return t;
}
}
代码示例来源:origin: konsoletyper/teavm-javac
@Override
public boolean compatible(Type found, Type req, Warner warn) {
found = pendingInferenceContext.asUndetVar(found);
if (found.hasTag(UNDETVAR) && req.isPrimitive()) {
req = types.boxedClass(req).type;
}
return super.compatible(found, req, warn);
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
static Type makeClassType(Types types, Type type) {
Type arg = type.isPrimitive()
? types.boxedClass(type).type
: types.erasure(type);
return new Type.ClassType(types.syms.classType.getEnclosingType(),
List.of(arg),
types.syms.classType.tsym);
}
public String toString() {
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
static Type makeClassType(Types types, Type type) {
Type arg = type.isPrimitive()
? types.boxedClass(type).type
: types.erasure(type);
return new Type.ClassType(types.syms.classType.getEnclosingType(),
List.of(arg),
types.syms.classType.tsym);
}
public String toString() {
代码示例来源:origin: sc.fiji/javac
static Type makeClassType(Types types, Type type) {
Type arg = type.isPrimitive()
? types.boxedClass(type).type
: types.erasure(type);
return new Type.ClassType(types.syms.classType.getEnclosingType(),
List.of(arg),
types.syms.classType.tsym);
}
public String toString() {
代码示例来源:origin: konsoletyper/teavm-javac
static Type makeClassType(Types types, Type type) {
Type arg = type.isPrimitive()
? types.boxedClass(type).type
: types.erasure(type);
return new Type.ClassType(types.syms.classType.getEnclosingType(),
List.of(arg),
types.syms.classType.tsym);
}
public String toString() {
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
/**
* Is t a subtype of or convertiable via boxing/unboxing
* convertions to s?
*/
public boolean isConvertible(Type t, Type s, Warner warn) {
boolean tPrimitive = t.isPrimitive();
boolean sPrimitive = s.isPrimitive();
if (tPrimitive == sPrimitive)
return isSubtypeUnchecked(t, s, warn);
if (!allowBoxing) return false;
return tPrimitive
? isSubtype(boxedClass(t).type, s)
: isSubtype(unboxedType(t), s);
}
代码示例来源:origin: com.google.errorprone/error_prone_core
private DoubleAndFloatStatus doubleAndFloatStatus(
VisitorState state, Type recieverType, Type argType) {
Types types = state.getTypes();
if (!types.isSameType(recieverType, state.getSymtab().floatType)) {
return DoubleAndFloatStatus.NONE;
}
if (types.isSameType(argType, types.boxedClass(state.getSymtab().doubleType).type)) {
return DoubleAndFloatStatus.BOXED_DOUBLE_INTO_FLOAT;
}
if (types.isSameType(argType, state.getSymtab().doubleType)) {
return DoubleAndFloatStatus.PRIMITIVE_DOUBLE_INTO_FLOAT;
}
return DoubleAndFloatStatus.NONE;
}
内容来源于网络,如有侵权,请联系作者删除!