Pre-SIP: sealed enumerating allowed sub-types

Coming from here, I can identify with many arguments, namely that

  • sealed (A, B, C, D) trait T { ...} is a very elegant solution (I suggested an annotation, which implies no change needed to the parser)
  • the main issue with sealed is the artificial restriction to put everything into one file, and this can get messy and be a lot of work to join, so that eventually you do not seal types that should be sealed in order to get exhaustive pattern matching
  • the Scala 3 union self-type is not a replacement for sealed traits; it looks very contrived and unclear
  • I disagree with Martin that the one-file-problem is solved by mixing in implementation traits that live in other files. First of all, they become visible. Second, they don’t solve the problem of huge companion objects that carry all sorts of serializers, type class instances etc.

I think such SIP would be very useful.

6 Likes