Widening Conversions on Arrays
There is a widening conversion between two array types if there is a widening reference conversion between their component types.
This is useful, but can lead to anomalies if used carelessly:
Circle [] bag = new Circle [N] ;
setAll(bag) ; // Widening: Circle [] to Shape [].
// OK at compile-time.
void setAll(Shape [] shapes) {
shapes [0] = new Circle() ;
shapes [1] = new Rectangle() ; // Widening: Rectangle to Shape.
// But throws ArrayStoreException
. . . // if invoked as above!
}
Effect would be to assign Rectangle to array of Circles. Requires the compiler to add a new kind or run-time check.