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

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

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

Types.boxedTypeOrType介绍

[英]Return the boxed type if 't' is primitive, otherwise return 't' itself.
[中]如果“t”是基元,则返回装箱类型,否则返回“t”本身。

代码示例

代码示例来源:origin: google/error-prone

private boolean isValidArrayFill(
  VisitorState state, Type arrayComponentType, Type fillingObjectType) {
 if (arrayComponentType == null || fillingObjectType == null) {
  return true; // shrug
 }
 return ASTHelpers.isSubtype(
   state.getTypes().boxedTypeOrType(fillingObjectType), arrayComponentType, state);
}

代码示例来源:origin: google/error-prone

private static Fix adjustHashCodeCall(MethodInvocationTree tree, VisitorState state) {
  String argumentClass =
    state
      .getTypes()
      .boxedTypeOrType(ASTHelpers.getType(tree.getArguments().get(0)))
      .tsym
      .getSimpleName()
      .toString();
  return SuggestedFix.builder()
    .prefixWith(tree, argumentClass + ".hashCode(")
    .replace(tree, state.getSourceForNode(tree.getArguments().get(0)))
    .postfixWith(tree, ")")
    .build();
 }
}

代码示例来源:origin: com.google.errorprone/error_prone_core

private boolean isValidArrayFill(
  VisitorState state, Type arrayComponentType, Type fillingObjectType) {
 if (arrayComponentType == null || fillingObjectType == null) {
  return true; // shrug
 }
 return ASTHelpers.isSubtype(
   state.getTypes().boxedTypeOrType(fillingObjectType), arrayComponentType, state);
}

代码示例来源:origin: com.google.errorprone/error_prone_core

private static Fix adjustHashCodeCall(MethodInvocationTree tree, VisitorState state) {
  String argumentClass =
    state
      .getTypes()
      .boxedTypeOrType(ASTHelpers.getType(tree.getArguments().get(0)))
      .tsym
      .getSimpleName()
      .toString();
  return SuggestedFix.builder()
    .prefixWith(tree, argumentClass + ".hashCode(")
    .replace(tree, state.getSourceForNode(tree.getArguments().get(0)))
    .postfixWith(tree, ")")
    .build();
 }
}

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

public static boolean checkTypesAssignable(CompilationInfo info, TypeMirror from, TypeMirror to) {
  Context c = ((JavacTaskImpl) info.impl.getJavacTask()).getContext();
  if (from.getKind() == TypeKind.TYPEVAR) {
    Types types = Types.instance(c);
    TypeVar t = types.substBound((TypeVar)from, com.sun.tools.javac.util.List.of((Type)from), com.sun.tools.javac.util.List.of(types.boxedTypeOrType((Type)to)));
    return info.getTypes().isAssignable(t.getUpperBound(), to)
        || info.getTypes().isAssignable(to, t.getUpperBound());
  }
  if (from.getKind() == TypeKind.WILDCARD) {
    from = Types.instance(c).wildUpperBound((Type)from);
  }
  return Check.instance(c).checkType(null, (Type)from, (Type)to).getKind() != TypeKind.ERROR;
}

相关文章

Types类方法