--- old/src/share/classes/com/sun/tools/javac/comp/TransTypes.java 2009-12-27 19:02:18.000000000 +0100 +++ new/src/share/classes/com/sun/tools/javac/comp/TransTypes.java 2009-12-27 19:02:18.000000000 +0100 @@ -446,12 +446,12 @@ result = tree; } - JCMethodDecl currentMethod = null; + Type currentReturnType = null; public void visitMethodDef(JCMethodDecl tree) { tree.sym.typeAnnotations = tree.sym.typeAnnotations; - JCMethodDecl previousMethod = currentMethod; + Type previousReturnType = currentReturnType; try { - currentMethod = tree; + currentReturnType = tree.sym.erasure(types).getReturnType(); tree.restype = translate(tree.restype, null); tree.typarams = List.nil(); tree.params = translateVarDefs(tree.params); @@ -460,7 +460,7 @@ tree.type = erasure(tree.type); result = tree; } finally { - currentMethod = previousMethod; + currentReturnType = previousReturnType; } // Check that we do not introduce a name clash by erasing types. @@ -558,7 +558,7 @@ } public void visitReturn(JCReturn tree) { - tree.expr = translate(tree.expr, currentMethod.sym.erasure(types).getReturnType()); + tree.expr = translate(tree.expr, currentReturnType); result = tree; } @@ -654,6 +654,19 @@ tree.expr = translate(tree.expr, tree.type); result = tree; } + + public void visitLambda(JCLambda tree) { + Type previousReturnType = currentReturnType; + try { + currentReturnType = tree.sym.erasure(types).getReturnType(); + tree.parameters = translateVarDefs(tree.parameters); + tree.bodyOrExpr = translate(tree.bodyOrExpr, tree.sym.erasure(types).getReturnType()); + tree.type = erasure(tree.type); + result = tree; + } finally { + currentReturnType = previousReturnType; + } + } public void visitTypeTest(JCInstanceOf tree) { tree.expr = translate(tree.expr, null);