tcltest::test 15.16-primitive-1 { Except for boolean, (primitive) primitive
        is always legal } {
    empty_main T1516p1 {
	boolean b = (boolean) true;
    }
} PASS

tcltest::test 15.16-primitive-2 { Except for boolean, (primitive) primitive
        is always legal } {
    empty_main T1516p2 {
	boolean b = (boolean) 1;
    }
} FAIL

tcltest::test 15.16-primitive-3 { Except for boolean, (primitive) primitive
        is always legal } {
    empty_main T1516p3 {
	int i = (int) true;
    }
} FAIL

tcltest::test 15.16-primitive-4 { Except for boolean, (primitive) primitive
        is always legal } {
    empty_main T1516p4 {
	int i = (int) 1;
    }
} PASS

tcltest::test 15.16-primitive-5 { Except for boolean, (primitive) primitive
        is always legal } {
    empty_main T1516p5 {
	double d = (double) 1;
    }
} PASS

tcltest::test 15.16-primitive-6 { Except for boolean, (primitive) primitive
        is always legal } {
    empty_main T1516p6 {
	int i = (int) 1.0;
    }
} PASS

tcltest::test 15.16-primitive-7 { Except for boolean, (primitive) primitive
        is always legal } {
    empty_main T1516p7 {
	int i = (int) '1';
    }
} PASS

tcltest::test 15.16-primitive-8 { (primitive) non-primitive is never legal } {
    empty_main T1516p8 {
	int i = (int) "1";
    }
} FAIL

tcltest::test 15.16-primitive-9 { (primitive) non-primitive is never legal } {
    empty_main T1516p9 {
	int i = (int) new Integer(1);
    }
} FAIL

tcltest::test 15.16-primitive-10 { (primitive) non-primitive is never legal } {
    empty_main T1516p10 {
	int i = (int) null;
    }
} FAIL

tcltest::test 15.16-primitive-11 { (primitive) non-primitive is never legal } {
    empty_main T1516p11 {
	int i = (int) System.out.println();
    }
} FAIL

tcltest::test 15.16-value-1 { casts create values, not variables } {
    empty_main T1516v1 {
	int i = 1;
	((int) i)++;
    }
} FAIL

tcltest::test 15.16-value-2 { casts create values, not variables } {
    empty_main T1516v2 {
	int i = 1;
	++(int) i;
    }
} FAIL

tcltest::test 15.16-value-3 { casts create values, not variables } {
    empty_main T1516v3 {
	int i;
	(long) i = 1;
    }
} FAIL

tcltest::test 15.16-value-4 { casts create values, not variables } {
    empty_main T1516v4 {
	int i;
	((long) i) = 1;
    }
} FAIL

tcltest::test 15.16-array-1 { array type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516a1 {
	int[] i = {};
	long[] l = (long[]) i;
    }
} FAIL

tcltest::test 15.16-array-2 { array type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516a2 {
	int[] i = {};
	int[] l = (int[]) i;
    }
} PASS

tcltest::test 15.16-array-3 { array type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516a3 {
	int[] i = {};
	Object o = (Object) i;
    }
} PASS

tcltest::test 15.16-array-4 { array type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516a4 {
	int[][] i = {};
	Cloneable c = (Cloneable) i;
    }
} PASS

tcltest::test 15.16-array-5 { array type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516a5 {
	int[][][] i = {};
	java.io.Serializable[] s = (java.io.Serializable[]) i;
    }
} PASS

tcltest::test 15.16-array-6 { array type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516a6 {
	Object[][][] o = {};
	java.io.Serializable[] s = (java.io.Serializable[]) o;
    }
} PASS

tcltest::test 15.16-array-7 { array type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516a7 {
	Object o = null;
	Cloneable[] s = (Cloneable[]) o;
    }
} PASS

tcltest::test 15.16-array-8 { array type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516a8 {
	Error[] o = null;
	Cloneable[][] s = (Cloneable[][]) o;
    }
} FAIL

tcltest::test 15.16-array-9 { array type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516a9 {
	Cloneable[][] s = (Cloneable[][]) (Object) (Integer[]) (Cloneable)
	                  (int[]) null;
    }
} PASS

tcltest::test 15.16-array-10 { array type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516a10 {
	class A {}
	class B {}
	B[] b = (B[]) new A[0];
    }
} FAIL

tcltest::test 15.16-array-11 { array type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516a11 {
	Runnable[] r = (Runnable[]) new String[0];
    }
} FAIL

tcltest::test 15.16-array-12 { array type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_class T1516a12 {
	interface I {}
	class C {}
	I[] i = (I[]) new C[0];
    }
} PASS

tcltest::test 15.16-array-13 { array type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_class T1516a13 {
	interface I { int m(); }
	class C { void m() {} }
	I[] i = (I[]) new C[0];
    }
} PASS

tcltest::test 15.16-array-14 { array type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_class T1516a14 {
	interface I {}
	interface J {}
	I[] i = (I[]) new J[0];
    }
} PASS

tcltest::test 15.16-array-15 { array type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_class T1516a15 {
	interface I { int m(); }
	interface J { void m(); }
	I[] i = (I[]) new J[0];
    }
} FAIL

tcltest::test 15.16-ref-1 { reference type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516r1 {
	Object o = null;
	String s = (String) o;
    }
} PASS

tcltest::test 15.16-ref-2 { reference type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516r2 {
	String o = null;
	String s = (String) o;
    }
} PASS

tcltest::test 15.16-ref-3 { reference type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516r3 {
	String s = null;
	Object o = (Object) s;
    }
} PASS

tcltest::test 15.16-ref-4 { reference type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516r4 {
	class A {}
	class B {}
	B b = (B) new A();
    }
} FAIL

tcltest::test 15.16-ref-5 { reference type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_main T1516r5 {
	Runnable r = (Runnable) "";
    }
} FAIL

tcltest::test 15.16-ref-6 { reference type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_class T1516r6 {
	interface I {}
	class C {}
	I i = (I) new C();
    }
} PASS

tcltest::test 15.16-ref-7 { reference type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_class T1516r7 {
	interface I { int m(); }
	class C { void m() {} }
	I i = (I) new C();
    }
} PASS

tcltest::test 15.16-ref-8 { reference type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_class T1516r8 {
	interface I {}
	interface J {}
	void m(J j) {
	    I i = (I) j;
	}
    }
} PASS

tcltest::test 15.16-ref-9 { reference type casting is legal if a widening or
        narrowing conversion can be made } {
    empty_class T1516r9 {
	interface I { int m(); }
	interface J { void m(); }
	void m(J j) {
	    I i = (I) j;
	}
    }
} FAIL

tcltest::test 15.16-semantic-1 { To avoid grammar ambiguities, this syntax is
        accepted; semantics must reject it } {
    empty_class T1516s1 {
	Object o = (int[]) + 5;
    }
} FAIL

tcltest::test 15.16-semantic-2 { To avoid grammar ambiguities, this syntax is
        accepted; semantics must reject it } {
    empty_class T1516s2 {
	Object o = (T1516s2) + "";
    }
} FAIL

tcltest::test 15.16-semantic-3 { To avoid grammar ambiguities, this syntax is
        accepted; semantics must reject it } {
    empty_class T1516s3 {
	Object o = (T1516s3 + "") null;
    }
} FAIL

tcltest::test 15.16-semantic-4 { To avoid grammar ambiguities, this syntax is
        accepted; semantics must reject it } {
    empty_main T1516s4 {
	// Because (String) is followed by +, it is an expression not a cast
	int String;
	Object o = (String) + 1 + "";
    }
} FAIL

tcltest::test 15.16-semantic-5 { To avoid grammar ambiguities, this syntax is
        accepted } {
    empty_main T1516s5 {
	// Because (String) is followed by +, it is an expression not a cast
	final int String = 1;
	switch (String) {
	    case 0:
	    case ((String) + 1 + "") == "2" ? 1 : 0:
	}
    }
} PASS
