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

public class Reflect {
    public static final class Pair {
        public int first;
        public int second;
        public separable Pair(int f, int s) {
            first = f;
            second = s;
        }
    }
    public static final class ContainsCode {
        public Code<Integer> c;
        public separable ContainsCode(final int i) {
            c = <| i |>;
        }
    }
    public static class NotFinal {
        public int i;
        public separable NotFinal(int f) {
            i = f;
        }
    }
    
    public static void main(String[] args) throws Exception {
        ClassCode<Pair> cp = new ClassCode<Pair>(Pair.class);
        FieldCode<Pair,Integer> fpf = cp.getField("first");
        final Pair p = new Pair(1,2);
        Code<Pair> c = <| p |>;
        Code<Integer> fpfc = fpf.get(c);
        System.out.println(fpfc.run());
        final ContainsCode error1 = new ContainsCode(1);
        // Code<ContainsCode> error1c = <| error1 |>; // error
        final NotFinal error2 = new NotFinal(1);
        // Code<NotFinal> error2c = <| error2 |>;
    }
}
