1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Aug 30 17:36:47 2013 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Sep 02 22:38:36 2013 +0100 1.3 @@ -2396,35 +2396,11 @@ 1.4 new ResultInfo(VAL, lambdaType.getReturnType(), funcContext); 1.5 localEnv.info.returnResult = bodyResultInfo; 1.6 1.7 - Log.DeferredDiagnosticHandler lambdaDeferredHandler = new Log.DeferredDiagnosticHandler(log); 1.8 - try { 1.9 - if (that.getBodyKind() == JCLambda.BodyKind.EXPRESSION) { 1.10 - attribTree(that.getBody(), localEnv, bodyResultInfo); 1.11 - } else { 1.12 - JCBlock body = (JCBlock)that.body; 1.13 - attribStats(body.stats, localEnv); 1.14 - } 1.15 - 1.16 - if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE) { 1.17 - //check for errors in lambda body 1.18 - for (JCDiagnostic deferredDiag : lambdaDeferredHandler.getDiagnostics()) { 1.19 - if (deferredDiag.getKind() == JCDiagnostic.Kind.ERROR) { 1.20 - resultInfo.checkContext 1.21 - .report(that, diags.fragment("bad.arg.types.in.lambda", TreeInfo.types(that.params), 1.22 - deferredDiag)); //hidden diag parameter 1.23 - //we mark the lambda as erroneous - this is crucial in the recovery step 1.24 - //as parameter-dependent type error won't be reported in that stage, 1.25 - //meaning that a lambda will be deemed erroeneous only if there is 1.26 - //a target-independent error (which will cause method diagnostic 1.27 - //to be skipped). 1.28 - result = that.type = types.createErrorType(target); 1.29 - return; 1.30 - } 1.31 - } 1.32 - } 1.33 - } finally { 1.34 - lambdaDeferredHandler.reportDeferredDiagnostics(); 1.35 - log.popDiagnosticHandler(lambdaDeferredHandler); 1.36 + if (that.getBodyKind() == JCLambda.BodyKind.EXPRESSION) { 1.37 + attribTree(that.getBody(), localEnv, bodyResultInfo); 1.38 + } else { 1.39 + JCBlock body = (JCBlock)that.body; 1.40 + attribStats(body.stats, localEnv); 1.41 } 1.42 1.43 result = check(that, target, VAL, resultInfo); 1.44 @@ -3731,7 +3707,7 @@ 1.45 * Check that method arguments conform to its instantiation. 1.46 **/ 1.47 public Type checkMethod(Type site, 1.48 - Symbol sym, 1.49 + final Symbol sym, 1.50 ResultInfo resultInfo, 1.51 Env<AttrContext> env, 1.52 final List<JCExpression> argtrees, 1.53 @@ -3820,8 +3796,19 @@ 1.54 resultInfo.checkContext.report(env.tree.pos(), ex.getDiagnostic()); 1.55 return types.createErrorType(site); 1.56 } catch (Resolve.InapplicableMethodException ex) { 1.57 - Assert.error(ex.getDiagnostic().getMessage(Locale.getDefault())); 1.58 - return null; 1.59 + final JCDiagnostic diag = ex.getDiagnostic(); 1.60 + Resolve.InapplicableSymbolError errSym = rs.new InapplicableSymbolError(null) { 1.61 + @Override 1.62 + protected Pair<Symbol, JCDiagnostic> errCandidate() { 1.63 + return new Pair<Symbol, JCDiagnostic>(sym, diag); 1.64 + } 1.65 + }; 1.66 + List<Type> argtypes2 = Type.map(argtypes, 1.67 + rs.new ResolveDeferredRecoveryMap(AttrMode.CHECK, sym, env.info.pendingResolutionPhase)); 1.68 + JCDiagnostic errDiag = errSym.getDiagnostic(JCDiagnostic.DiagnosticType.ERROR, 1.69 + env.tree, sym, site, sym.name, argtypes2, typeargtypes); 1.70 + log.report(errDiag); 1.71 + return types.createErrorType(site); 1.72 } 1.73 } 1.74