本文整理了Java中com.sun.tools.javac.code.Types.lowerBound()
方法的一些代码示例,展示了Types.lowerBound()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.lowerBound()
方法的具体详情如下:
包路径:com.sun.tools.javac.code.Types
类名称:Types
方法名:lowerBound
[英]The "lvalue conversion".
The lower bound of most types is the type itself. Wildcards, on the other hand have upper and lower bounds.
[中]“左值转换”。
大多数类型的下限是类型本身。另一方面,通配符有上界和下界。
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
public Type apply(Type t) {
return lowerBound(t);
}
};
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
public Type apply(Type t) {
return lowerBound(t);
}
};
代码示例来源:origin: sc.fiji/javac
public Type apply(Type t) {
return lowerBound(t);
}
};
代码示例来源:origin: sc.fiji/javac
public Type visitType(Type t, Void s) {
return high ? upperBound(t) : lowerBound(t);
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
public Type visitType(Type t, Void s) {
return high ? upperBound(t) : lowerBound(t);
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
void debugContainsType(WildcardType t, Type s) {
System.err.println();
System.err.format(" does %s contain %s?%n", t, s);
System.err.format(" %s U(%s) <: U(%s) %s = %s%n",
upperBound(s), s, t, U(t),
t.isSuperBound()
|| isSubtypeNoCapture(upperBound(s), U(t)));
System.err.format(" %s L(%s) <: L(%s) %s = %s%n",
L(t), t, s, lowerBound(s),
t.isExtendsBound()
|| isSubtypeNoCapture(L(t), lowerBound(s)));
System.err.println();
}
代码示例来源:origin: sc.fiji/javac
void debugContainsType(WildcardType t, Type s) {
System.err.println();
System.err.format(" does %s contain %s?%n", t, s);
System.err.format(" %s U(%s) <: U(%s) %s = %s%n",
upperBound(s), s, t, U(t),
t.isSuperBound()
|| isSubtypeNoCapture(upperBound(s), U(t)));
System.err.format(" %s L(%s) <: L(%s) %s = %s%n",
L(t), t, s, lowerBound(s),
t.isExtendsBound()
|| isSubtypeNoCapture(L(t), lowerBound(s)));
System.err.println();
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
@Override
public Void visitWildcardType(WildcardType source, Type target) throws AdaptFailure {
if (source.isExtendsBound())
adaptRecursive(upperBound(source), upperBound(target));
else if (source.isSuperBound())
adaptRecursive(lowerBound(source), lowerBound(target));
return null;
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
public boolean isSubtype(Type t, Type s, boolean capture) {
if (t == s)
return true;
if (s.tag >= firstPartialTag)
return isSuperType(s, t);
Type lower = lowerBound(s);
if (s != lower)
return isSubtype(capture ? capture(t) : t, lower, false);
return isSubtype.visit(capture ? capture(t) : t, s);
}
// where
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
@Override
public Boolean visitClassType(ClassType t, Type s) {
if (t == s)
return true;
if (s.tag >= firstPartialTag)
return visit(s, t);
if (s.isSuperBound() && !s.isExtendsBound())
return visit(t, upperBound(s)) && visit(t, lowerBound(s));
if (t.isCompound() && s.isCompound()) {
if (!visit(supertype(t), supertype(s)))
return false;
HashSet<SingletonType> set = new HashSet<SingletonType>();
for (Type x : interfaces(t))
set.add(new SingletonType(x));
for (Type x : interfaces(s)) {
if (!set.remove(new SingletonType(x)))
return false;
}
return (set.size() == 0);
}
return t.tsym == s.tsym
&& visit(t.getEnclosingType(), s.getEnclosingType())
&& containsTypeEquivalent(t.getTypeArguments(), s.getTypeArguments());
}
代码示例来源:origin: sc.fiji/javac
@Override
public Boolean visitWildcardType(WildcardType t, Type s) {
if (s.tag >= firstPartialTag)
return containedBy(s, t);
else {
// debugContainsType(t, s);
return isSameWildcard(t, s)
|| isCaptureOf(s, t)
|| ((t.isExtendsBound() || isSubtypeNoCapture(L(t), lowerBound(s))) &&
(t.isSuperBound() || isSubtypeNoCapture(upperBound(s), U(t))));
}
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
void validateAnnotationType(DiagnosticPosition pos, Type type) {
if (type.isPrimitive()) return;
if (types.isSameType(type, syms.stringType)) return;
if ((type.tsym.flags() & Flags.ENUM) != 0) return;
if ((type.tsym.flags() & Flags.ANNOTATION) != 0) return;
if (types.lowerBound(type).tsym == syms.classType.tsym) return;
if (types.isArray(type) && !types.isArray(types.elemtype(type))) {
validateAnnotationType(pos, types.elemtype(type));
return;
}
log.error(pos, "invalid.annotation.member.type");
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
@Override
public Boolean visitWildcardType(WildcardType t, Type s) {
if (s.tag >= firstPartialTag)
return containedBy(s, t);
else {
// debugContainsType(t, s);
return isSameWildcard(t, s)
|| isCaptureOf(s, t)
|| ((t.isExtendsBound() || isSubtypeNoCapture(L(t), lowerBound(s))) &&
(t.isSuperBound() || isSubtypeNoCapture(upperBound(s), U(t))));
}
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
void validateAnnotationType(DiagnosticPosition pos, Type type) {
if (type.isPrimitive()) return;
if (types.isSameType(type, syms.stringType)) return;
if ((type.tsym.flags() & Flags.ENUM) != 0) return;
if ((type.tsym.flags() & Flags.ANNOTATION) != 0) return;
if (types.lowerBound(type).tsym == syms.classType.tsym) return;
if (types.isArray(type) && !types.isArray(types.elemtype(type))) {
validateAnnotationType(pos, types.elemtype(type));
return;
}
log.error(pos, "invalid.annotation.member.type");
}
代码示例来源:origin: sc.fiji/javac
void validateAnnotationType(DiagnosticPosition pos, Type type) {
if (type.isPrimitive()) return;
if (types.isSameType(type, syms.stringType)) return;
if ((type.tsym.flags() & Flags.ENUM) != 0) return;
if ((type.tsym.flags() & Flags.ANNOTATION) != 0) return;
if (types.lowerBound(type).tsym == syms.classType.tsym) return;
if (types.isArray(type) && !types.isArray(types.elemtype(type))) {
validateAnnotationType(pos, types.elemtype(type));
return;
}
log.error(pos, "invalid.annotation.member.type");
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
@Override
public Boolean visitWildcardType(WildcardType t, Type s) {
if (s.isPartial())
return containedBy(s, t);
else {
// debugContainsType(t, s);
return isSameWildcard(t, s)
|| isCaptureOf(s, t)
|| ((t.isExtendsBound() || isSubtypeNoCapture(L(t), lowerBound(s))) &&
(t.isSuperBound() || isSubtypeNoCapture(upperBound(s), U(t))));
}
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
@Override
public Boolean visitClassType(ClassType t, Type s) {
if (t == s)
return true;
if (s.isPartial())
return visit(s, t);
if (s.isSuperBound() && !s.isExtendsBound())
return visit(t, upperBound(s)) && visit(t, lowerBound(s));
if (t.isCompound() && s.isCompound()) {
if (!visit(supertype(t), supertype(s)))
return false;
HashSet<UniqueType> set = new HashSet<UniqueType>();
for (Type x : interfaces(t))
set.add(new UniqueType(x.unannotatedType(), Types.this));
for (Type x : interfaces(s)) {
if (!set.remove(new UniqueType(x.unannotatedType(), Types.this)))
return false;
}
return (set.isEmpty());
}
return t.tsym == s.tsym
&& visit(t.getEnclosingType(), s.getEnclosingType())
&& containsTypes(t.getTypeArguments(), s.getTypeArguments());
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/** Check that a type is within some bounds.
*
* Used in TypeApply to verify that, e.g., X in {@code V<X>} is a valid
* type argument.
* @param a The type that should be bounded by bs.
* @param bound The bound.
*/
private boolean checkExtends(Type a, Type bound) {
if (a.isUnbound()) {
return true;
} else if (!a.hasTag(WILDCARD)) {
a = types.upperBound(a);
return types.isSubtype(a, bound);
} else if (a.isExtendsBound()) {
return types.isCastable(bound, types.upperBound(a), types.noWarnings);
} else if (a.isSuperBound()) {
return !types.notSoftSubtype(types.lowerBound(a), bound);
}
return true;
}
代码示例来源:origin: sc.fiji/javac
public boolean isSubtype(Type t, Type s, boolean capture) {
if (t == s)
return true;
if (s.tag >= firstPartialTag)
return isSuperType(s, t);
if (s.isCompound()) {
for (Type s2 : interfaces(s).prepend(supertype(s))) {
if (!isSubtype(t, s2, capture))
return false;
}
return true;
}
Type lower = lowerBound(s);
if (s != lower)
return isSubtype(capture ? capture(t) : t, lower, false);
return isSubtype.visit(capture ? capture(t) : t, s);
}
// where
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
@Override
public Boolean visitWildcardType(WildcardType t, Type s) {
if (t.isUnbound())
return false;
if (!s.hasTag(WILDCARD)) {
if (t.isExtendsBound())
return notSoftSubtypeRecursive(s, t.type);
else
return notSoftSubtypeRecursive(t.type, s);
}
if (s.isUnbound())
return false;
if (t.isExtendsBound()) {
if (s.isExtendsBound())
return !isCastableRecursive(t.type, upperBound(s));
else if (s.isSuperBound())
return notSoftSubtypeRecursive(lowerBound(s), t.type);
} else if (t.isSuperBound()) {
if (s.isExtendsBound())
return notSoftSubtypeRecursive(t.type, upperBound(s));
}
return false;
}
};
内容来源于网络,如有侵权,请联系作者删除!