compiler-design-eth/javali_tests/HW4_nop90/Casts/ErrCastUnrelatedType.javali

21 lines
274 B
Plaintext

// Test types in a Cast (cannot cast to unrelated type)
class Main {
void main() {
C1 a, b;
C2 c, d;
Object o;
c = new C2();
a = new C1();
b = (C1) c;
d = (C2) a;
o = (Object) a;
o = (Object) c;
o = (Main) c;
}
}
class C1 {}
class C2 extends C1{}