本文整理了Java中com.sun.tools.javac.code.Types.isSubtypeUnchecked()
方法的一些代码示例,展示了Types.isSubtypeUnchecked()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.isSubtypeUnchecked()
方法的具体详情如下:
包路径:com.sun.tools.javac.code.Types
类名称:Types
方法名:isSubtypeUnchecked
[英]Is t an unchecked subtype of s?
[中]t是未经检查的亚型吗?
代码示例来源:origin: google/error-prone
private boolean checkBounds(Unifier unifier, Inliner inliner, Warner warner)
throws CouldNotResolveImportException {
Types types = unifier.types();
ListBuffer<Type> varsBuffer = new ListBuffer<>();
ListBuffer<Type> bindingsBuffer = new ListBuffer<>();
for (UTypeVar typeVar : typeVariables(unifier.getContext())) {
varsBuffer.add(inliner.inlineAsVar(typeVar));
bindingsBuffer.add(unifier.getBinding(typeVar.key()).type());
}
List<Type> vars = varsBuffer.toList();
List<Type> bindings = bindingsBuffer.toList();
for (UTypeVar typeVar : typeVariables(unifier.getContext())) {
List<Type> bounds = types.getBounds(inliner.inlineAsVar(typeVar));
bounds = types.subst(bounds, vars, bindings);
if (!types.isSubtypeUnchecked(unifier.getBinding(typeVar.key()).type(), bounds, warner)) {
logger.log(
FINE,
String.format("%s is not a subtype of %s", inliner.getBinding(typeVar.key()), bounds));
return false;
}
}
return true;
}
代码示例来源:origin: konsoletyper/teavm-javac
/**
* Is t an unchecked subtype of s?
*/
public boolean isSubtypeUnchecked(Type t, Type s) {
return isSubtypeUnchecked(t, s, noWarnings);
}
/**
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
/**
* Is t an unchecked subtype of s?
*/
public boolean isSubtypeUnchecked(Type t, Type s) {
return isSubtypeUnchecked(t, s, Warner.noWarnings);
}
/**
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
@Override
boolean apply(Type op1, Type op2, Warner warn, Types types) {
return types.isSubtypeUnchecked(op1, op2, warn);
}
},
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/**
* Is t an unchecked subtype of s?
*/
public boolean isSubtypeUnchecked(Type t, Type s) {
return isSubtypeUnchecked(t, s, noWarnings);
}
/**
代码示例来源:origin: sc.fiji/javac
/**
* Is t an unchecked subtype of s?
*/
public boolean isSubtypeUnchecked(Type t, Type s) {
return isSubtypeUnchecked(t, s, Warner.noWarnings);
}
/**
代码示例来源:origin: konsoletyper/teavm-javac
@Override
boolean apply(Type op1, Type op2, Warner warn, Types types) {
return types.isSubtypeUnchecked(op1, op2, warn);
}
},
代码示例来源:origin: sc.fiji/javac
/**
* 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();*/
}
// </editor-fold>
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/**
* Is t a subtype of every type in given list `ts'?<br>
* (not defined for Method and ForAll types)<br>
* Allows unchecked conversions.
*/
public boolean isSubtypeUnchecked(Type t, List<Type> ts, Warner warn) {
for (List<Type> l = ts; l.nonEmpty(); l = l.tail)
if (!isSubtypeUnchecked(t, l.head, warn))
return false;
return true;
}
代码示例来源:origin: sc.fiji/javac
/**
* Is t a subtype of every type in given list `ts'?<br>
* (not defined for Method and ForAll types)<br>
* Allows unchecked conversions.
*/
public boolean isSubtypeUnchecked(Type t, List<Type> ts, Warner warn) {
for (List<Type> l = ts; l.nonEmpty(); l = l.tail)
if (!isSubtypeUnchecked(t, l.head, warn))
return false;
return true;
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
/**
* Is t a subtype of every type in given list `ts'?<br>
* (not defined for Method and ForAll types)<br>
* Allows unchecked conversions.
*/
public boolean isSubtypeUnchecked(Type t, List<Type> ts, Warner warn) {
for (List<Type> l = ts; l.nonEmpty(); l = l.tail)
if (!isSubtypeUnchecked(t, l.head, warn))
return false;
return true;
}
代码示例来源:origin: konsoletyper/teavm-javac
/**
* Is t a subtype of every type in given list `ts'?<br>
* (not defined for Method and ForAll types)<br>
* Allows unchecked conversions.
*/
public boolean isSubtypeUnchecked(Type t, List<Type> ts, Warner warn) {
for (List<Type> l = ts; l.nonEmpty(); l = l.tail)
if (!isSubtypeUnchecked(t, l.head, warn))
return false;
return true;
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
public boolean compatible(Type found, Type req, Warner warn) {
return strict ?
types.isSubtypeUnchecked(found, deferredAttrContext.inferenceContext.asFree(req), warn) :
types.isConvertible(found, deferredAttrContext.inferenceContext.asFree(req), warn);
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
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;
}
代码示例来源:origin: konsoletyper/teavm-javac
public boolean compatible(Type found, Type req, Warner warn) {
InferenceContext inferenceContext = deferredAttrContext.inferenceContext;
return strict ?
types.isSubtypeUnchecked(inferenceContext.asUndetVar(found), inferenceContext.asUndetVar(req), warn) :
types.isConvertible(inferenceContext.asUndetVar(found), inferenceContext.asUndetVar(req), warn);
}
代码示例来源:origin: konsoletyper/teavm-javac
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;
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
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(), JCDiagnostic.fragment("incompatible.types"), actual, formal);
throw new AssertionError("Tree: " + tree
+ " actual:" + actual
+ " formal: " + formal);
}
}
代码示例来源:origin: sc.fiji/javac
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(), JCDiagnostic.fragment("incompatible.types"), actual, formal);
throw new AssertionError("Tree: " + tree
+ " actual:" + actual
+ " formal: " + formal);
}
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
@Override
ReferenceLookupHelper unboundLookup(InferenceContext inferenceContext) {
if (TreeInfo.isStaticSelector(referenceTree.expr, names) &&
argtypes.nonEmpty() &&
(argtypes.head.hasTag(NONE) ||
types.isSubtypeUnchecked(inferenceContext.asFree(argtypes.head), site))) {
return new UnboundMethodReferenceLookupHelper(referenceTree, name,
site, argtypes, typeargtypes, maxPhase);
} else {
return super.unboundLookup(inferenceContext);
}
}
代码示例来源:origin: konsoletyper/teavm-javac
@Override
ReferenceLookupHelper unboundLookup(InferenceContext inferenceContext) {
if (TreeInfo.isStaticSelector(referenceTree.expr, names) &&
argtypes.nonEmpty() &&
(argtypes.head.hasTag(NONE) ||
types.isSubtypeUnchecked(inferenceContext.asUndetVar(argtypes.head), site))) {
return new UnboundMethodReferenceLookupHelper(referenceTree, name,
site, argtypes, typeargtypes, maxPhase);
} else {
return super.unboundLookup(inferenceContext);
}
}
内容来源于网络,如有侵权,请联系作者删除!