Assume the structure:
sealed class Shape permits Circle, Quadrangle {}
sealed class Quadrangle extends Shape permits Diamond, Rectangle { }
final class Rectangle extends Quadrangle {}
final class Diamond extends Quadrangle {}
final class Circle extends Shape {}
Then when I have e.g. such switch statement:
switch (shape) {
case Rectangle _-> System.out.println("");
case Diamond _-> System.out.println("");
case Circle _-> System.out.println("");
}
I have information about not covering all cases and forced to implement default. In my opinion this is some bug or something. It should not be that way. As I cover all cases.
Is there a way to achieve the exhaustiveness of the switch statement and if yes then how?