Skip to content

Instantly share code, notes, and snippets.

Created June 6, 2016 11:04
  • Star 14 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Scala type which can only be extended by an object, not by a non-abstract type ...
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
Copy link

RSchulz commented Jun 7, 2016

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!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment