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

public class SeparableSample9 {
    static int sfield = 0;
    int field = 0;
    SafeCode<Integer> cc;
    Code<Integer> dd;
    int[] arrayField = new int[10];
    IntPair pair = new IntPair();
    NotFinal notFinal;

    public static final class IntPair {
	public int i;
	public int j;
    }

    public static class NotFinal { }

    public static separable SafeCode<Integer> getCodeOne() { return <| 1 |>; }
    public static separable int getOne() { return 1; }

    public separable void sepMethod() {
	sfield = 1;
	field = 1;
	// cc = <| 1 |>; // error
	// dd = <| 1 |>; // error
	arrayField = new int[10];
	arrayField[0] = 1;
	pair = new IntPair();
	pair.i = 1;
	pair.j = 1;
	// notFinal = new NotFinal(); // error

	NotFinal localNotFinal = new NotFinal();
	Code<Integer> localCode = <| 1 |>;
	SafeCode<Integer> localCode2 = <| 2 |>;
    }

    { 
	sfield = 1;
	field = 1;
	// cc = <| 1 |>; // error
	// dd = <| 1 |>; // error
	arrayField = new int[10];
	arrayField[0] = 1;
	pair = new IntPair();
	pair.i = 1;
	pair.j = 1;
    }

    public separable SeparableSample9() {
	// separable ctor, i.e. all initializers must be separable
    }

    public static Code<Integer> statCode;

    public static void main(String[] args) {
	final Code<Integer>[] da = new Code[1];
	// Code<Integer> c = <| `(let Code<Integer> c = <| 1 |>; da[0] = <| 2 |>) |>; // error
	// Code<Integer> c = <| `(let Code<Integer> c = <| 1 |>; statCode = <| 2 |>) |>; // error
	Code<Integer> c = <| `(let Code<Integer> c = <| 1 |>; c = <| 2 |>) |>;
	System.out.println(c.run());
    }
}
