But the fact that the following is unsound (and has been for a while) will always remain a mystery to me:
public class Main {
class Animal {}
class Dog extends Animal {}
class Cat extends Animal {}
public static void main (String[] args) {
Main x = new Main();
Dog[] doges = new Dog[10];
x.t(doges);
}
public void t(Animal[] bar) {
bar[0] = new Cat();
bar[0] = new Animal(); // also breaks
}
}
The array type seems completely tractable and may be able to be caught by the compiler.