Community
Participate
Working Groups
Build: 3.0 M2 Given the following three compilation units: package p1; public class A { void foo() { } } --- package p2; import p1.A; public class B extends A { } --- package p1; import p2.B; public class C { public void bar() { B b = new B(); ((A)b).foo();//warning for necessary cast } } The new warning for unnecessary casts reports a warning in C on the commented line. If the cast is removed, a compile error results (due to visibility restriction), therefore this cast IS necessary.
Did not consider alternate receiver type, only argument types.
Fixed. Added regression test (NegativeTest#test395)
Access to member types also had a similar defficiency (replace (A)b.foo() with (A)b.new Member(), with A defining member type.
Verified.