Well, not quite. A
sealed type can only have direct subtypes in the same source file. But the constraint is not transitive and these subtypes, not being
sealed themselves, can have subtypes declared in other files.
For example, having this in one file:
sealed trait Foo class Bar extends Foo
We can absolutely extend
Bar in another source file:
class FooBar extends Bar
This is perfectly correct as per the definition of
sealed, and sometimes even desirable. It’s just not what most people expect.
For this reason, it’s preferable to default to
final subtypes unless you have a good reason for them not to be.