How to use Scala's singleton-object types?
问题 I'm writing a class which serves as base class for a series of singleton objects. In each singleton objects, there will be vals representing certain properties, and I want to write a method which, for each singleton object, only accepts objects created by it. So I have the following: class Obj[M <: Maker] class Maker { implicit val me: this.type = this def make[M <: Maker](implicit maker: M) = new Obj[M] def accept(obj: Obj[this.type]) = {...} } So far, so good. Then I want to declare one of