langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
changeset 16808 90b98d194b75
parent 16805 b419336382fd
child 16809 5acfcb821d65
equal deleted inserted replaced
16807:b442b47d3ae9 16808:90b98d194b75
  2338             ResultInfo bodyResultInfo = lambdaType.getReturnType() == Type.recoveryType ?
  2338             ResultInfo bodyResultInfo = lambdaType.getReturnType() == Type.recoveryType ?
  2339                 recoveryInfo :
  2339                 recoveryInfo :
  2340                 new ResultInfo(VAL, lambdaType.getReturnType(), funcContext);
  2340                 new ResultInfo(VAL, lambdaType.getReturnType(), funcContext);
  2341             localEnv.info.returnResult = bodyResultInfo;
  2341             localEnv.info.returnResult = bodyResultInfo;
  2342 
  2342 
  2343             if (that.getBodyKind() == JCLambda.BodyKind.EXPRESSION) {
  2343             Log.DeferredDiagnosticHandler lambdaDeferredHandler = new Log.DeferredDiagnosticHandler(log);
  2344                 attribTree(that.getBody(), localEnv, bodyResultInfo);
  2344             try {
  2345             } else {
  2345                 if (that.getBodyKind() == JCLambda.BodyKind.EXPRESSION) {
  2346                 JCBlock body = (JCBlock)that.body;
  2346                     attribTree(that.getBody(), localEnv, bodyResultInfo);
  2347                 attribStats(body.stats, localEnv);
  2347                 } else {
       
  2348                     JCBlock body = (JCBlock)that.body;
       
  2349                     attribStats(body.stats, localEnv);
       
  2350                 }
       
  2351 
       
  2352                 if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE) {
       
  2353                     //check for errors in lambda body
       
  2354                     for (JCDiagnostic deferredDiag : lambdaDeferredHandler.getDiagnostics()) {
       
  2355                         if (deferredDiag.getKind() == JCDiagnostic.Kind.ERROR) {
       
  2356                             resultInfo.checkContext
       
  2357                                     .report(that, diags.fragment("bad.arg.types.in.lambda", TreeInfo.types(that.params)));
       
  2358                             //we mark the lambda as erroneous - this is crucial in the recovery step
       
  2359                             //as parameter-dependent type error won't be reported in that stage,
       
  2360                             //meaning that a lambda will be deemed erroeneous only if there is
       
  2361                             //a target-independent error (which will cause method diagnostic
       
  2362                             //to be skipped).
       
  2363                             result = that.type = types.createErrorType(target);
       
  2364                             return;
       
  2365                         }
       
  2366                     }
       
  2367                 }
       
  2368             } finally {
       
  2369                 lambdaDeferredHandler.reportDeferredDiagnostics();
       
  2370                 log.popDiagnosticHandler(lambdaDeferredHandler);
  2348             }
  2371             }
  2349 
  2372 
  2350             result = check(that, target, VAL, resultInfo);
  2373             result = check(that, target, VAL, resultInfo);
  2351 
  2374 
  2352             boolean isSpeculativeRound =
  2375             boolean isSpeculativeRound =