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

public class SeparableSample7 {
    public static int unsafeMethod() {
        return 2;
    }
    public static separable int safeMethod() {
        return 2;
    }
    public static void main (String [] args) {
        SafeCode<Integer> sc  = <| safeMethod() |>; // ok
        // SafeCode<Integer> sc2 = <| unsafeMethod() |>; // error
        Code<Integer> uc      = <| safeMethod() |>; // ok
        Code<Integer> uc2     = <| unsafeMethod() |>; // ok
        
        SafeCode<Integer> sc3 = <| `(<|safeMethod()|>) |>; // ok
        // SafeCode<Integer> sc4 = <| `(<|unsafeMethod()|>) |>; // error
        Code<Integer> uc3     = <| `(<|safeMethod()|>) |>; // ok
        Code<Integer> uc4     = <| `(<|unsafeMethod()|>) |>; // ok
        
        SafeCode<Integer> sc5 = <| `( <| `( <|safeMethod()|>) |>) |>; // ok
        // SafeCode<Integer> sc6 = <| `( <| `( <|unsafeMethod()|>) |>) |>; // error
        Code<Integer> uc5     = <| `( <| `( <|safeMethod()|>) |>) |>; // ok
        // Code<Integer> uc6     = <| `( <| `( <|unsafeMethod()|>) |>) |>; // error
        
        SafeCode<? extends Runnable> sc7 = <|
            new Runnable() { public void run() { int i = safeMethod(); } }
        |>; // ok
        SafeCode<? extends Runnable> sc8 = <|
            new Runnable() { public void run() { int i = unsafeMethod(); } }
        |>; // ok
        Code<? extends Runnable> uc7 = <|
            new Runnable() { public void run() { int i = safeMethod(); } }
        |>; // ok
        Code<? extends Runnable> uc8 = <|
            new Runnable() { public void run() { int i = unsafeMethod(); } }
        |>; // ok
        
        SafeCode<? extends Runnable> sc9 = <|
            new Runnable() { public void run() { int i = `(<|safeMethod()|>); } }
        |>; // ok
        SafeCode<? extends Runnable> sc10 = <|
            new Runnable() { public void run() { int i = `(<|unsafeMethod()|>); } }
        |>; // ok
        Code<? extends Runnable> uc9 = <|
            new Runnable() { public void run() { int i = `(<|safeMethod()|>); } }
        |>; // ok
        Code<? extends Runnable> uc10 = <|
            new Runnable() { public void run() { int i = `(<|unsafeMethod()|>); } }
        |>; // ok
        
        SafeCode<? extends Runnable> sc11 = <|
            new Runnable() { public void run() { int i = `(<|`(<|safeMethod()|>)|>); } }
        |>; // ok
        // SafeCode<? extends Runnable> sc12 = <|
        //     new Runnable() { public void run() { int i = `(<|`(<|unsafeMethod()|>)|>); } }
        //     |>; // error
        Code<? extends Runnable> uc11 = <|
            new Runnable() { public void run() { int i = `(<|`(<|safeMethod()|>)|>); } }
        |>; // ok
        // Code<? extends Runnable> uc12 = <|
        //     new Runnable() { public void run() { int i = `(<|`(<|unsafeMethod()|>)|>); } }
        //     |>; // error
    }
}
