当前位置: 首页>>代码示例>>Java>>正文


Java Warner类代码示例

本文整理汇总了Java中com.sun.tools.javac.util.Warner的典型用法代码示例。如果您正苦于以下问题:Java Warner类的具体用法?Java Warner怎么用?Java Warner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Warner类属于com.sun.tools.javac.util包,在下文中一共展示了Warner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkUnsafeVarargsConversion

import com.sun.tools.javac.util.Warner; //导入依赖的package包/类
private void checkUnsafeVarargsConversion(Type t, Type s, Warner warn) {
    if (t.tag != ARRAY || isReifiable(t)) return;
    ArrayType from = (ArrayType)t;
    boolean shouldWarn = false;
    switch (s.tag) {
        case ARRAY:
            ArrayType to = (ArrayType)s;
            shouldWarn = from.isVarargs() &&
                    !to.isVarargs() &&
                    !isReifiable(from);
            break;
        case CLASS:
            shouldWarn = from.isVarargs();
            break;
    }
    if (shouldWarn) {
        warn.warn(LintCategory.VARARGS);
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:20,代码来源:Types.java

示例2: isCastable

import com.sun.tools.javac.util.Warner; //导入依赖的package包/类
/**
 * Is t is castable to s?<br>
 * s is assumed to be an erased type.<br>
 * (not defined for Method and ForAll types).
 */
public boolean isCastable(Type t, Type s, Warner warn) {
    if (t == s)
        return true;

    if (t.isPrimitive() != s.isPrimitive())
        return allowBoxing && (
                isConvertible(t, s, warn)
                || (allowObjectToPrimitiveCast &&
                    s.isPrimitive() &&
                    isSubtype(boxedClass(s).type, t)));
    if (warn != warnStack.head) {
        try {
            warnStack = warnStack.prepend(warn);
            checkUnsafeVarargsConversion(t, s, warn);
            return isCastable.visit(t,s);
        } finally {
            warnStack = warnStack.tail;
        }
    } else {
        return isCastable.visit(t,s);
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:28,代码来源:Types.java

示例3: visitArrayType

import com.sun.tools.javac.util.Warner; //导入依赖的package包/类
@Override
public Boolean visitArrayType(ArrayType t, Type s) {
    switch (s.tag) {
    case ERROR:
    case BOT:
        return true;
    case TYPEVAR:
        if (isCastable(s, t, Warner.noWarnings)) {
            warnStack.head.warn(LintCategory.UNCHECKED);
            return true;
        } else {
            return false;
        }
    case CLASS:
        return isSubtype(t, s);
    case ARRAY:
        if (elemtype(t).tag <= lastBaseTag ||
                elemtype(s).tag <= lastBaseTag) {
            return elemtype(t).tag == elemtype(s).tag;
        } else {
            return visit(elemtype(t), elemtype(s));
        }
    default:
        return false;
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:27,代码来源:Types.java

示例4: visitTypeVar

import com.sun.tools.javac.util.Warner; //导入依赖的package包/类
@Override
public Boolean visitTypeVar(TypeVar t, Type s) {
    switch (s.tag) {
    case ERROR:
    case BOT:
        return true;
    case TYPEVAR:
        if (isSubtype(t, s)) {
            return true;
        } else if (isCastable(t.bound, s, Warner.noWarnings)) {
            warnStack.head.warn(LintCategory.UNCHECKED);
            return true;
        } else {
            return false;
        }
    default:
        return isCastable(t.bound, s, warnStack.head);
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:20,代码来源:Types.java

示例5: returnTypeSubstitutable

import com.sun.tools.javac.util.Warner; //导入依赖的package包/类
public boolean returnTypeSubstitutable(Type r1,
                                       Type r2, Type r2res,
                                       Warner warner) {
    if (isSameType(r1.getReturnType(), r2res))
        return true;
    if (r1.getReturnType().isPrimitive() || r2res.isPrimitive())
        return false;

    if (hasSameArgs(r1, r2))
        return covariantReturnType(r1.getReturnType(), r2res, warner);
    if (!allowCovariantReturns)
        return false;
    if (isSubtypeUnchecked(r1.getReturnType(), r2res, warner))
        return true;
    if (!isSubtype(r1.getReturnType(), erasure(r2res)))
        return false;
    warner.warn(LintCategory.UNCHECKED);
    return true;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:20,代码来源:Types.java

示例6: solveLegacy

import com.sun.tools.javac.util.Warner; //导入依赖的package包/类
/**
 * Instantiate inference variables in legacy mode (JLS 15.12.2.7, 15.12.2.8).
 * During overload resolution, instantiation is done by doing a partial
 * inference process using eq/lower bound instantiation. During check,
 * we also instantiate any remaining vars by repeatedly using eq/upper
 * instantiation, until all variables are solved.
 */
public void solveLegacy(boolean partial, Warner warn, EnumSet<InferenceStep> steps) {
    while (true) {
        List<Type> solvedVars = solveBasic(steps);
        if (restvars().isEmpty() || partial) {
            //all variables have been instantiated - exit
            break;
        } else if (solvedVars.isEmpty()) {
            //some variables could not be instantiated because of cycles in
            //upper bounds - provide a (possibly recursive) default instantiation
            infer.instantiateAsUninferredVars(restvars(), this);
            break;
        } else {
            //some variables have been instantiated - replace newly instantiated
            //variables in remaining upper bounds and continue
            for (Type t : undetvars) {
                UndetVar uv = (UndetVar)t;
                uv.substBounds(solvedVars, asInstTypes(solvedVars), types);
            }
        }
    }
    infer.doIncorporation(this, warn);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:InferenceContext.java

示例7: match

import com.sun.tools.javac.util.Warner; //导入依赖的package包/类
@Nullable
private Unifier match(List<JCStatement> targetStatements, Context context) {
  checkArgument(templateStatements().size() == targetStatements.size());
  Unifier unifier = new Unifier(context);
  for (int i = 0; i < templateStatements().size() && unifier != null; i++) {
    unifier = templateStatements().get(i).unify(targetStatements.get(i), unifier);
  }
  if (unifier != null) {
    Inliner inliner = unifier.createInliner();
    try {
      return typecheck(
          unifier, inliner, new Warner(targetStatements.get(0)), expectedTypes(inliner),
          actualTypes(inliner));
    } catch (CouldNotResolveImportException e) {
      logger.log(FINE, "Failure to resolve import", e);
    }
  }
  return null;
}
 
开发者ID:sivakumar-kailasam,项目名称:refactor-faster,代码行数:20,代码来源:BlockTemplate.java

示例8: unify

import com.sun.tools.javac.util.Warner; //导入依赖的package包/类
@Override
@Nullable
public Unifier unify(JCExpression target, Unifier unifier) {
  unifier = expression().unify(target, unifier);
  if (unifier != null) {
    Inliner inliner = unifier.createInliner();
    try {
      List<Type> expectedTypes = expectedTypes(inliner);
      List<Type> actualTypes = actualTypes(inliner);
      /*
       * The Java compiler's type inference doesn't directly take into account the expected
       * return type, so we test the return type by treating the expected return type as an
       * extra method argument, and the actual type of the return expression as its actual
       * value.
       */
      expectedTypes = expectedTypes.prepend(returnType().inline(inliner));
      actualTypes = actualTypes.prepend(target.type);

      return typecheck(unifier, inliner, new Warner(target), expectedTypes, actualTypes);
    } catch (CouldNotResolveImportException e) {
      logger.log(FINE, "Failure to resolve import", e);
    }
  }
  return null;
}
 
开发者ID:sivakumar-kailasam,项目名称:refactor-faster,代码行数:26,代码来源:ExpressionTemplate.java

示例9: infer

import com.sun.tools.javac.util.Warner; //导入依赖的package包/类
/**
 * Returns the inferred method type of the template based on the given actual argument types.
 *
 * @throws NoInstanceException if no instances of the specified type variables would allow the
 *         {@code actualArgTypes} to match the {@code expectedArgTypes}
 */
private Type infer(Warner warner,
    Inliner inliner,
    List<Type> freeTypeVariables,
    List<Type> expectedArgTypes,
    Type returnType,
    List<Type> actualArgTypes) throws NoInstanceException {
  Symtab symtab = inliner.symtab();
  MethodType methodType =
      new MethodType(expectedArgTypes, returnType, List.<Type>nil(), symtab.methodClass);
  Enter enter = inliner.enter();
  MethodSymbol methodSymbol =
      new MethodSymbol(0, inliner.asName("__m__"), methodType, symtab.unknownSymbol);
  return inliner.infer().instantiateMethod(enter.getEnv(methodType.tsym),
      freeTypeVariables,
      methodType,
      methodSymbol,
      actualArgTypes,
      autoboxing(),
      false,
      warner);
}
 
开发者ID:sivakumar-kailasam,项目名称:refactor-faster,代码行数:28,代码来源:Template.java

示例10: assertConvertible

import com.sun.tools.javac.util.Warner; //导入依赖的package包/类
private void assertConvertible(JCTree tree, Type actual, Type formal, Warner warn) {
    if (types.isConvertible(actual, formal, warn))
        return;

    if (formal.isCompound()
        && types.isSubtype(actual, types.supertype(formal))
        && types.isSubtypeUnchecked(actual, types.interfaces(formal), warn))
        return;

    if (false) {
        // TODO: make assertConvertible work
        chk.typeError(tree.pos(), diags.fragment("incompatible.types"), actual, formal);
        throw new AssertionError("Tree: " + tree
                                 + " actual:" + actual
                                 + " formal: " + formal);
    }
}
 
开发者ID:sebastianoe,项目名称:s4j,代码行数:18,代码来源:Attr.java

示例11: isConvertible

import com.sun.tools.javac.util.Warner; //导入依赖的package包/类
/**
 * Is t a subtype of or convertible via boxing/unboxing
 * conversion to s?
 */
public boolean isConvertible(Type t, Type s, Warner warn) {
    if (t.tag == ERROR)
        return true;
    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);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:18,代码来源:Types.java

示例12: isSubtypeUnchecked

import com.sun.tools.javac.util.Warner; //导入依赖的package包/类
/**
 * Is t an unchecked subtype of s?
 */
public boolean isSubtypeUnchecked(Type t, Type s, Warner warn) {
    boolean result = isSubtypeUncheckedInternal(t, s, warn);
    if (result) {
        checkUnsafeVarargsConversion(t, s, warn);
    }
    return result;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:11,代码来源:Types.java

示例13: isSubtypeUncheckedInternal

import com.sun.tools.javac.util.Warner; //导入依赖的package包/类
private boolean isSubtypeUncheckedInternal(Type t, Type s, Warner warn) {
    if (t.tag == ARRAY && s.tag == ARRAY) {
        if (((ArrayType)t).elemtype.tag <= lastBaseTag) {
            return isSameType(elemtype(t), elemtype(s));
        } else {
            return isSubtypeUnchecked(elemtype(t), elemtype(s), warn);
        }
    } else if (isSubtype(t, s)) {
        return true;
    }
    else if (t.tag == TYPEVAR) {
        return isSubtypeUnchecked(t.getUpperBound(), s, warn);
    }
    else if (s.tag == UNDETVAR) {
        UndetVar uv = (UndetVar)s;
        if (uv.inst != null)
            return isSubtypeUnchecked(t, uv.inst, warn);
    }
    else if (!s.isRaw()) {
        Type t2 = asSuper(t, s.tsym);
        if (t2 != null && t2.isRaw()) {
            if (isReifiable(s))
                warn.silentWarn(LintCategory.UNCHECKED);
            else
                warn.warn(LintCategory.UNCHECKED);
            return true;
        }
    }
    return false;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:31,代码来源:Types.java

示例14: isSubtypesUnchecked

import com.sun.tools.javac.util.Warner; //导入依赖的package包/类
/**
 * Are corresponding elements of ts subtypes of ss, allowing
 * unchecked conversions?  If lists are of different length,
 * return false.
 **/
public boolean isSubtypesUnchecked(List<Type> ts, List<Type> ss, Warner warn) {
    while (ts.tail != null && ss.tail != null
           /*inlined: ts.nonEmpty() && ss.nonEmpty()*/ &&
           isSubtypeUnchecked(ts.head, ss.head, warn)) {
        ts = ts.tail;
        ss = ss.tail;
    }
    return ts.tail == null && ss.tail == null;
    /*inlined: ts.isEmpty() && ss.isEmpty();*/
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:16,代码来源:Types.java

示例15: notSoftSubtype

import com.sun.tools.javac.util.Warner; //导入依赖的package包/类
/**
 * This relation answers the question: is impossible that
 * something of type `t' can be a subtype of `s'? This is
 * different from the question "is `t' not a subtype of `s'?"
 * when type variables are involved: Integer is not a subtype of T
 * where <T extends Number> but it is not true that Integer cannot
 * possibly be a subtype of T.
 */
public boolean notSoftSubtype(Type t, Type s) {
    if (t == s) return false;
    if (t.tag == TYPEVAR) {
        TypeVar tv = (TypeVar) t;
        return !isCastable(tv.bound,
                           relaxBound(s),
                           Warner.noWarnings);
    }
    if (s.tag != WILDCARD)
        s = upperBound(s);

    return !isSubtype(t, relaxBound(s));
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:22,代码来源:Types.java


注:本文中的com.sun.tools.javac.util.Warner类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。