public class Main { static class A {} static class B extends A {} static class X { } static class Y extends X { } private void test1(X x) { Y y = (Y) x; } private void test2(X x) { Y y = (Y) x; } private void test3(Y y1) { @SuppressWarnings("unchecked") Y y2 = (Y) y1; } }