本文整理汇总了Java中com.sun.tools.javac.comp.Check.CheckContext类的典型用法代码示例。如果您正苦于以下问题:Java CheckContext类的具体用法?Java CheckContext怎么用?Java CheckContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CheckContext类属于com.sun.tools.javac.comp.Check包,在下文中一共展示了CheckContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: checkLambdaCompatible
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
/**
* 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"));
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:Attr.java
示例2: methodCheckResult
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
private ResultInfo methodCheckResult(final boolean varargsCheck, Type to,
final DeferredAttr.DeferredAttrContext deferredAttrContext, Warner rsWarner) {
CheckContext checkContext = new MethodCheckContext(!deferredAttrContext.phase.isBoxingRequired(), deferredAttrContext, rsWarner) {
MethodCheckDiag methodDiag = varargsCheck ?
MethodCheckDiag.VARARG_MISMATCH : MethodCheckDiag.ARG_MISMATCH;
@Override
public boolean compatible(Type found, Type req, Warner warn) {
found = pendingInferenceContext.asUndetVar(found);
if (found.hasTag(UNDETVAR) && req.isPrimitive()) {
req = types.boxedClass(req).type;
}
return super.compatible(found, req, warn);
}
@Override
public void report(DiagnosticPosition pos, JCDiagnostic details) {
reportMC(pos, methodDiag, deferredAttrContext.inferenceContext, details);
}
};
return new MethodResultInfo(to, checkContext);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:Resolve.java
示例3: checkLambdaCompatible
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
/**
* 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.
*/
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) {
Fragment msg =
Fragments.IncompatibleRetTypeInLambda(Fragments.MissingRetVal(returnType));
checkContext.report(tree,
diags.fragment(msg));
}
List<Type> argTypes = checkContext.inferenceContext().asUndetVars(descriptor.getParameterTypes());
if (!types.isSameTypes(argTypes, TreeInfo.types(tree.params))) {
checkContext.report(tree, diags.fragment(Fragments.IncompatibleArgTypesInLambda));
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:Attr.java
示例4: checkLambdaCompatible
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
/**
* 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.
*/
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"));
}
}
开发者ID:campolake,项目名称:openjdk9,代码行数:25,代码来源:Attr.java
示例5: checkLambdaCompatible
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
/**
* 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"));
}
}
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:25,代码来源:Attr.java
示例6: methodCheckResult
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
private ResultInfo methodCheckResult(final boolean varargsCheck, Type to,
final DeferredAttr.DeferredAttrContext deferredAttrContext, Warner rsWarner) {
CheckContext checkContext = new MethodCheckContext(!deferredAttrContext.phase.isBoxingRequired(), deferredAttrContext, rsWarner) {
MethodCheckDiag methodDiag = varargsCheck ?
MethodCheckDiag.VARARG_MISMATCH : MethodCheckDiag.ARG_MISMATCH;
@Override
public boolean compatible(Type found, Type req, Warner warn) {
found = pendingInferenceContext.asFree(found);
req = infer.returnConstraintTarget(found, req);
return super.compatible(found, req, warn);
}
@Override
public void report(DiagnosticPosition pos, JCDiagnostic details) {
reportMC(pos, methodDiag, deferredAttrContext.inferenceContext, details);
}
};
return new MethodResultInfo(to, checkContext);
}
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:21,代码来源:Resolve.java
示例7: checkReferenceCompatible
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
@SuppressWarnings("fallthrough")
void checkReferenceCompatible(JCMemberReference tree, Type descriptor, Type refType, CheckContext checkContext, boolean speculativeAttr) {
Type returnType = checkContext.inferenceContext().asUndetVar(descriptor.getReturnType());
Type resType;
switch (tree.getMode()) {
case NEW:
if (!tree.expr.type.isRaw()) {
resType = tree.expr.type;
break;
}
default:
resType = refType.getReturnType();
}
Type incompatibleReturnType = resType;
if (returnType.hasTag(VOID)) {
incompatibleReturnType = null;
}
if (!returnType.hasTag(VOID) && !resType.hasTag(VOID)) {
if (resType.isErroneous() ||
new FunctionalReturnContext(checkContext).compatible(resType, returnType, types.noWarnings)) {
incompatibleReturnType = null;
}
}
if (incompatibleReturnType != null) {
checkContext.report(tree, diags.fragment("incompatible.ret.type.in.mref",
diags.fragment("inconvertible.types", resType, descriptor.getReturnType())));
}
if (!speculativeAttr) {
List<Type> thrownTypes = checkContext.inferenceContext().asUndetVars(descriptor.getThrownTypes());
if (chk.unhandled(refType.getThrownTypes(), thrownTypes).nonEmpty()) {
log.error(tree, "incompatible.thrown.types.in.mref", refType.getThrownTypes());
}
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:Attr.java
示例8: ResultInfo
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
protected ResultInfo(KindSelector pkind,
Type pt, CheckContext checkContext, CheckMode checkMode) {
this.pkind = pkind;
this.pt = pt;
this.checkContext = checkContext;
this.checkMode = checkMode;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:Attr.java
示例9: conditionalContext
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
CheckContext conditionalContext(CheckContext checkContext) {
return new Check.NestedCheckContext(checkContext) {
//this will use enclosing check context to check compatibility of
//subexpression against target type; if we are in a method check context,
//depending on whether boxing is allowed, we could have incompatibilities
@Override
public void report(DiagnosticPosition pos, JCDiagnostic details) {
enclosingContext.report(pos, diags.fragment(Fragments.IncompatibleTypeInConditional(details)));
}
};
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:Attr.java
示例10: diamondContext
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
CheckContext diamondContext(JCNewClass clazz, TypeSymbol tsym, CheckContext checkContext) {
return new Check.NestedCheckContext(checkContext) {
@Override
public void report(DiagnosticPosition _unused, JCDiagnostic details) {
enclosingContext.report(clazz.clazz,
diags.fragment(Fragments.CantApplyDiamond1(Fragments.Diamond(tsym), details)));
}
};
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Attr.java
示例11: checkLambdaCompatible
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
/** Check lambda against given target result */
private void checkLambdaCompatible(Type descriptor, ResultInfo resultInfo) {
CheckContext checkContext = resultInfo.checkContext;
ResultInfo bodyResultInfo = attr.lambdaBodyResult(speculativeTree, descriptor, resultInfo);
for (JCReturn ret : returnExpressions()) {
Type t = getReturnType(ret);
if (speculativeTree.getBodyKind() == BodyKind.EXPRESSION || !t.hasTag(VOID)) {
checkSpeculative(ret.expr, t, bodyResultInfo);
}
}
attr.checkLambdaCompatible(speculativeTree, descriptor, checkContext);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ArgumentAttr.java
示例12: conditionalContext
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
CheckContext conditionalContext(CheckContext checkContext) {
return new Check.NestedCheckContext(checkContext) {
//this will use enclosing check context to check compatibility of
//subexpression against target type; if we are in a method check context,
//depending on whether boxing is allowed, we could have incompatibilities
@Override
public void report(DiagnosticPosition pos, JCDiagnostic details) {
enclosingContext.report(pos, diags.fragment("incompatible.type.in.conditional", details));
}
};
}
开发者ID:campolake,项目名称:openjdk9,代码行数:12,代码来源:Attr.java
示例13: diamondContext
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
CheckContext diamondContext(JCNewClass clazz, TypeSymbol tsym, CheckContext checkContext) {
return new Check.NestedCheckContext(checkContext) {
@Override
public void report(DiagnosticPosition _unused, JCDiagnostic details) {
enclosingContext.report(clazz.clazz,
diags.fragment("cant.apply.diamond.1", diags.fragment("diamond", tsym), details));
}
};
}
开发者ID:campolake,项目名称:openjdk9,代码行数:10,代码来源:Attr.java
示例14: checkReferenceCompatible
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
@SuppressWarnings("fallthrough")
void checkReferenceCompatible(JCMemberReference tree, Type descriptor, Type refType, CheckContext checkContext, boolean speculativeAttr) {
Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType());
Type resType;
switch (tree.getMode()) {
case NEW:
if (!tree.expr.type.isRaw()) {
resType = tree.expr.type;
break;
}
default:
resType = refType.getReturnType();
}
Type incompatibleReturnType = resType;
if (returnType.hasTag(VOID)) {
incompatibleReturnType = null;
}
if (!returnType.hasTag(VOID) && !resType.hasTag(VOID)) {
if (resType.isErroneous() ||
new FunctionalReturnContext(checkContext).compatible(resType, returnType, types.noWarnings)) {
incompatibleReturnType = null;
}
}
if (incompatibleReturnType != null) {
checkContext.report(tree, diags.fragment("incompatible.ret.type.in.mref",
diags.fragment("inconvertible.types", resType, descriptor.getReturnType())));
}
if (!speculativeAttr) {
List<Type> thrownTypes = checkContext.inferenceContext().asFree(descriptor.getThrownTypes());
if (chk.unhandled(refType.getThrownTypes(), thrownTypes).nonEmpty()) {
log.error(tree, "incompatible.thrown.types.in.mref", refType.getThrownTypes());
}
}
}
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:41,代码来源:Attr.java
示例15: ResultInfo
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
protected ResultInfo(int pkind, Type pt, CheckContext checkContext) {
this.pkind = pkind;
this.pt = pt;
this.checkContext = checkContext;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:Attr.java
示例16: dup
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
protected ResultInfo dup(CheckContext newContext) {
return new ResultInfo(pkind, pt, newContext);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:Attr.java
示例17: visitTry
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
public void visitTry(JCTry tree) {
// Create a new local environment with a local
Env<AttrContext> localEnv = env.dup(tree, env.info.dup(env.info.scope.dup()));
try {
boolean isTryWithResource = tree.resources.nonEmpty();
// Create a nested environment for attributing the try block if needed
Env<AttrContext> tryEnv = isTryWithResource ?
env.dup(tree, localEnv.info.dup(localEnv.info.scope.dup())) :
localEnv;
try {
// Attribute resource declarations
for (JCTree resource : tree.resources) {
CheckContext twrContext = new Check.NestedCheckContext(resultInfo.checkContext) {
@Override
public void report(DiagnosticPosition pos, JCDiagnostic details) {
chk.basicHandler.report(pos, diags.fragment("try.not.applicable.to.type", details));
}
};
ResultInfo twrResult = new ResultInfo(VAL, syms.autoCloseableType, twrContext);
if (resource.hasTag(VARDEF)) {
attribStat(resource, tryEnv);
twrResult.check(resource, resource.type);
//check that resource type cannot throw InterruptedException
checkAutoCloseable(resource.pos(), localEnv, resource.type);
VarSymbol var = ((JCVariableDecl) resource).sym;
var.setData(ElementKind.RESOURCE_VARIABLE);
} else {
attribTree(resource, tryEnv, twrResult);
}
}
// Attribute body
attribStat(tree.body, tryEnv);
} finally {
if (isTryWithResource)
tryEnv.info.scope.leave();
}
// Attribute catch clauses
for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
JCCatch c = l.head;
Env<AttrContext> catchEnv =
localEnv.dup(c, localEnv.info.dup(localEnv.info.scope.dup()));
try {
Type ctype = attribStat(c.param, catchEnv);
if (TreeInfo.isMultiCatch(c)) {
//multi-catch parameter is implicitly marked as final
c.param.sym.flags_field |= FINAL | UNION;
}
if (c.param.sym.kind == Kinds.VAR) {
c.param.sym.setData(ElementKind.EXCEPTION_PARAMETER);
}
chk.checkType(c.param.vartype.pos(),
chk.checkClassType(c.param.vartype.pos(), ctype),
syms.throwableType);
attribStat(c.body, catchEnv);
} finally {
catchEnv.info.scope.leave();
}
}
// Attribute finalizer
if (tree.finalizer != null) attribStat(tree.finalizer, localEnv);
result = null;
}
finally {
localEnv.info.scope.leave();
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:71,代码来源:Attr.java
示例18: FunctionalReturnContext
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
FunctionalReturnContext(CheckContext enclosingContext) {
super(enclosingContext);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:Attr.java
示例19: ExpressionLambdaReturnContext
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
ExpressionLambdaReturnContext(JCExpression expr, CheckContext enclosingContext) {
super(enclosingContext);
this.expr = expr;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:Attr.java
示例20: MethodResultInfo
import com.sun.tools.javac.comp.Check.CheckContext; //导入依赖的package包/类
public MethodResultInfo(Type pt, CheckContext checkContext) {
attr.super(VAL, pt, checkContext);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:Resolve.java
注:本文中的com.sun.tools.javac.comp.Check.CheckContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论