本文整理了Java中com.sun.tools.javac.code.Types.isSameTypes()
方法的一些代码示例,展示了Types.isSameTypes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.isSameTypes()
方法的具体详情如下:
包路径:com.sun.tools.javac.code.Types
类名称:Types
方法名:isSameTypes
[英]Are corresponding elements of the lists the same type? If lists are of different length, return false.
[中]列表中对应的元素是同一类型的吗?如果列表长度不同,则返回false。
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/**
* Are corresponding elements of the lists the same type? If
* lists are of different length, return false.
*/
public boolean isSameTypes(List<Type> ts, List<Type> ss) {
return isSameTypes(ts, ss, false);
}
public boolean isSameTypes(List<Type> ts, List<Type> ss, boolean strict) {
代码示例来源:origin: konsoletyper/teavm-javac
/**
* Are corresponding elements of the lists the same type? If
* lists are of different length, return false.
*/
public boolean isSameTypes(List<Type> ts, List<Type> ss) {
return isSameTypes(ts, ss, false);
}
public boolean isSameTypes(List<Type> ts, List<Type> ss, boolean strict) {
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
@Override
protected boolean containsTypes(List<Type> ts1, List<Type> ts2) {
return isSameTypes(ts1, ts2, true);
}
代码示例来源:origin: konsoletyper/teavm-javac
@Override
protected boolean containsTypes(List<Type> ts1, List<Type> ts2) {
return isSameTypes(ts1, ts2, true);
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/** @see com.sun.tools.javadoc.ClassDocImpl */
private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) {
if (paramTypes == null)
return true;
if (method.params().size() != paramTypes.size())
return false;
List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes();
return (Type.isErroneous(paramTypes))
? fuzzyMatch(paramTypes, methodParamTypes)
: types.isSameTypes(paramTypes, methodParamTypes);
}
代码示例来源:origin: konsoletyper/teavm-javac
/** @see com.sun.tools.javadoc.ClassDocImpl */
private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) {
if (paramTypes == null)
return true;
if (method.params().size() != paramTypes.size())
return false;
List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes();
return (Type.isErroneous(paramTypes))
? fuzzyMatch(paramTypes, methodParamTypes)
: types.isSameTypes(paramTypes, methodParamTypes);
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/**
* Lambda compatibility. Check that given return types, thrown types, parameter types
* are compatible with the expected functional interface descriptor. This means that:
* (i) parameter types must be identical to those of the target descriptor; (ii) return
* types must be compatible with the return type of the expected descriptor.
*/
private void checkLambdaCompatible(JCLambda tree, Type descriptor, CheckContext checkContext) {
Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType());
//return values have already been checked - but if lambda has no return
//values, we must ensure that void/value compatibility is correct;
//this amounts at checking that, if a lambda body can complete normally,
//the descriptor's return type must be void
if (tree.getBodyKind() == JCLambda.BodyKind.STATEMENT && tree.canCompleteNormally &&
!returnType.hasTag(VOID) && returnType != Type.recoveryType) {
checkContext.report(tree, diags.fragment("incompatible.ret.type.in.lambda",
diags.fragment("missing.ret.val", returnType)));
}
List<Type> argTypes = checkContext.inferenceContext().asFree(descriptor.getParameterTypes());
if (!types.isSameTypes(argTypes, TreeInfo.types(tree.params))) {
checkContext.report(tree, diags.fragment("incompatible.arg.types.in.lambda"));
}
}
代码示例来源:origin: konsoletyper/teavm-javac
/**
* Lambda compatibility. Check that given return types, thrown types, parameter types
* are compatible with the expected functional interface descriptor. This means that:
* (i) parameter types must be identical to those of the target descriptor; (ii) return
* types must be compatible with the return type of the expected descriptor.
*/
private void checkLambdaCompatible(JCLambda tree, Type descriptor, CheckContext checkContext) {
Type returnType = checkContext.inferenceContext().asUndetVar(descriptor.getReturnType());
//return values have already been checked - but if lambda has no return
//values, we must ensure that void/value compatibility is correct;
//this amounts at checking that, if a lambda body can complete normally,
//the descriptor's return type must be void
if (tree.getBodyKind() == JCLambda.BodyKind.STATEMENT && tree.canCompleteNormally &&
!returnType.hasTag(VOID) && returnType != Type.recoveryType) {
checkContext.report(tree, diags.fragment("incompatible.ret.type.in.lambda",
diags.fragment("missing.ret.val", returnType)));
}
List<Type> argTypes = checkContext.inferenceContext().asUndetVars(descriptor.getParameterTypes());
if (!types.isSameTypes(argTypes, TreeInfo.types(tree.params))) {
checkContext.report(tree, diags.fragment("incompatible.arg.types.in.lambda"));
}
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
@Override
public void visitLambda(JCLambda tree) {
if (types.isFunctionalInterface(t.tsym) &&
types.isFunctionalInterface(s.tsym)) {
Type desc_t = types.findDescriptorType(t);
Type desc_s = types.findDescriptorType(s);
if (types.isSameTypes(desc_t.getParameterTypes(),
inferenceContext().asFree(desc_s.getParameterTypes()))) {
if (types.asSuper(t, s.tsym) != null ||
types.asSuper(s, t.tsym) != null) {
result &= MostSpecificCheckContext.super.compatible(t, s, warn);
} else if (!desc_s.getReturnType().hasTag(VOID)) {
//perform structural comparison
Type ret_t = desc_t.getReturnType();
Type ret_s = desc_s.getReturnType();
scanLambdaBody(tree, ret_t, ret_s);
} else {
return;
}
}
} else {
result &= false;
}
}
//where
代码示例来源:origin: konsoletyper/teavm-javac
@Override
public void visitReference(JCMemberReference tree) {
Type desc_t = types.findDescriptorType(t);
Type desc_s = types.findDescriptorType(s);
// use inference variables here for more-specific inference (18.5.4)
if (!types.isSameTypes(desc_t.getParameterTypes(),
inferenceContext().asUndetVars(desc_s.getParameterTypes()))) {
result &= false;
} else {
// compare return types
Type ret_t = desc_t.getReturnType();
Type ret_s = desc_s.getReturnType();
if (ret_s.hasTag(VOID)) {
result &= true;
} else if (ret_t.hasTag(VOID)) {
result &= false;
} else if (ret_t.isPrimitive() != ret_s.isPrimitive()) {
boolean retValIsPrimitive =
tree.refPolyKind == PolyKind.STANDALONE &&
tree.sym.type.getReturnType().isPrimitive();
result &= (retValIsPrimitive == ret_t.isPrimitive()) &&
(retValIsPrimitive != ret_s.isPrimitive());
} else {
result &= MostSpecificCheckContext.super.compatible(ret_t, ret_s, warn);
}
}
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
@Override
public void visitReference(JCMemberReference tree) {
if (types.isFunctionalInterface(t.tsym) &&
types.isFunctionalInterface(s.tsym)) {
Type desc_t = types.findDescriptorType(t);
Type desc_s = types.findDescriptorType(s);
if (types.isSameTypes(desc_t.getParameterTypes(),
inferenceContext().asFree(desc_s.getParameterTypes()))) {
if (types.asSuper(t, s.tsym) != null ||
types.asSuper(s, t.tsym) != null) {
result &= MostSpecificCheckContext.super.compatible(t, s, warn);
} else if (!desc_s.getReturnType().hasTag(VOID)) {
//perform structural comparison
Type ret_t = desc_t.getReturnType();
Type ret_s = desc_s.getReturnType();
result &= ((tree.refPolyKind == PolyKind.STANDALONE)
? standaloneMostSpecific(ret_t, ret_s, tree.sym.type.getReturnType(), warn)
: polyMostSpecific(ret_t, ret_s, warn));
} else {
return;
}
}
} else {
result &= false;
}
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
if ((s2.flags() & ABSTRACT) == 0 ||
!types.overrideEquivalent(mt, mt2) ||
!types.isSameTypes(s.erasure(types).getParameterTypes(),
s2.erasure(types).getParameterTypes())) {
代码示例来源:origin: konsoletyper/teavm-javac
Type desc_s = types.findDescriptorType(s);
if (!types.isSameTypes(desc_t.getParameterTypes(),
inferenceContext().asUndetVars(desc_s.getParameterTypes()))) {
result &= false;
代码示例来源:origin: konsoletyper/teavm-javac
if ((s2.flags() & ABSTRACT) == 0 ||
!types.overrideEquivalent(mt, mt2) ||
!types.isSameTypes(s.erasure(types).getParameterTypes(),
s2.erasure(types).getParameterTypes())) {
代码示例来源:origin: sc.fiji/javac
Type s = types.asOuterSuper(site, sym.owner);
if (s != null && s.isRaw() &&
!types.isSameTypes(sym.type.getParameterTypes(),
sym.erasure(types).getParameterTypes())) {
chk.warnUnchecked(env.tree.pos(),
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
Type s = types.asOuterSuper(site, sym.owner);
if (s != null && s.isRaw() &&
!types.isSameTypes(sym.type.getParameterTypes(),
sym.erasure(types).getParameterTypes())) {
chk.warnUnchecked(env.tree.pos(),
代码示例来源:origin: konsoletyper/teavm-javac
Type s = types.asOuterSuper(site, sym.owner);
if (s != null && s.isRaw() &&
!types.isSameTypes(sym.type.getParameterTypes(),
sym.erasure(types).getParameterTypes())) {
chk.warnUnchecked(env.tree.pos(),
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
Type s = types.asOuterSuper(site, sym.owner);
if (s != null && s.isRaw() &&
!types.isSameTypes(sym.type.getParameterTypes(),
sym.erasure(types).getParameterTypes())) {
chk.warnUnchecked(env.tree.pos(),
内容来源于网络,如有侵权,请联系作者删除!