Re: non-exhaustive match warning for abstract type

Peter Corlett <[email protected]>
Newsgroups gmane.comp.lang.scala
Message-ID <[email protected]>
On 8 Feb 2015, at 01:07, Jim Newsham <[email protected]> wrote:
[...]
> I see.  That's rather peculiar to me.  I thought the whole point of sealed was to prevent subclasses outside of the single source file, in which case "new Abs() { }" seems to violate that.

Sealing isn't recursive. In your example, "sealed trait A" itself cannot be subclassed outside the file because it is marked sealed, but "abstract class Abs extends A" is not sealed and so can be subclassed. You will need to also mark it sealed if that is the behaviour you desire.

"new Abs() {}" works because Abs is not sealed, and not because this is magic syntax that ignores sealing.


-- 
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.