Open Blaisorblade opened 6 years ago
The semantics of sealed
is related to compilation-unit. It implies to take advantage of the knowledge that a sealed class cannot be extended outside of its compilation unit, the subtyping checker has to be compilation-unit aware, which seems difficult to implement.
Reported on Gitter by @ekrich. People often complain that you can match an A against an unrelated B — say, a
Set
againstList
. In most cases they're wrong (tho it's sometimes unfortunate), but for Set and List they seem to be right, because List is sealed and none of its descendents can be extended. Scalac gives no warning for this either. /cc @liufengyun