import edu.rice.cs.mint.runtime.*;

// no bug anymore, just left in here for illustration purposes
public final class ScopeBugSample {
    public static class Foo {
        public int fooField = 111;
        public void m() {
            System.out.println("m()");
        }
        public Code<Integer> n() {
            return <| 0 |>;
        }
    }
    
    public void run() {    
        Code<Void> c = <| {
            Foo f = new Foo() {
                public void m() {
                    // field reference okay here,
                    // anonymous inner class is closer
                    // than the brackets
                    fooField = 222;
                }
                public Code<Integer> n() {
                    final int fooCopy = fooField;
                    return <| fooCopy |>;
                    // return <| fooField |>; // error
                }
            }; 
            f.m();
            System.out.println(f.fooField);
        } |>;
        c.run ();
    }
    
    public static void main (String [] args) {
        new ScopeBugSample().run();
    }
}
