Scala type which can only be extended by an object, not by a non-abstract type ...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> class Foo { self: Singleton => } | |
defined class Foo | |
scala> class Bar extends Foo | |
<console>:12: error: illegal inheritance; | |
self-type Bar does not conform to Foo's selftype Foo with Singleton | |
class Bar extends Foo | |
^ | |
scala> object Bar extends Foo | |
defined object Bar | |
scala> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems like magic, since if you try to extend Singleton directly, you're chastised that Singleton is final! (Nor does it appear in the ScalaDoc!)