Scala - The sealed trait of a big child
While experimenting with sealed traits, I found (to my surprise) that if in one file I have this code
sealed trait sealed trait SealedChild extends Sealed
And in another file I have
trait SealedGrandchild extends SealedChild
Code compilation completed successfully.
Why can it be defined SealedGranchild
even if it is a closed ancestor type in another file? Aside from explicitly declaring SealedChild
how sealed
, is there a way to prevent the extension SealedChild
outside of the file where it is defined?
+3
source to share