If I read the rules correctly, Box(Soup) + Bag(Soup) "cover" Container<Lunch>, with the exception of the { null, Box(null), Bag(null) }. So the above will throw when `lunch` is null, and will also throw with Box(null) or Bag(null). Correct?


Correct (under the "we make switches total" plan.)

I realized there's also another remainder Box/Bag(*) - e.g. Box/Bag(Pizza), where Pizza is a new type that shows up in the sealed hierarchy.

To cover that (not that it's required at compile-time, just to imagine what javac would emit), we need probably one of these:

case Box b:

or

case Container c

Right?

Maurizio


Reply via email to