deduplicating lambda methods

Maurizio Cimadamore maurizio.cimadamore at
Fri Mar 16 18:46:28 UTC 2018

On 16/03/18 00:36, Liam Miller-Cushon wrote:
> Thanks, I'll investigate that. My initial impression is that using fields
> to replace the return value and the second parameter of the visit methods
> in TreeVisitor will complicate control flow somewhat.
> Have you considered adding a TreeVisitor-like API that for JCTrees to javac?
Having a tree scanner accepting a visitor parameter would be good - 
although can be done outside the scope of this patch.

Note that, in the meantime, it's rather easy to mimic the visitor 
parameter idiom - just define a 'scan' method like this:

Object parameter; //visitor field

scan(JCTree tree, Object parameter) {
    Object prev = this.parameter;
    try {
        this.parameter = parameter;
    } finally {
        this.parameter = prev;

And then your code should not be altered much (I hope! :-)).


More information about the amber-dev mailing list