title: How to use Scala's singleton-object types?
body: <p>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.</p>
  
  <p>So I have the following:</p>
  
  <pre><code>class Obj[M &lt;: Maker]
  
  class Maker {
    implicit val me: this.type = this
    def make[M &lt;: Maker](implicit maker: M) = new Obj[M]
    def accept(obj: Obj[this.type]) = {...}
  }
  </code></pre>
  
  <p>So far, so good. Then I want to declare one of these singleton objects:</p>
  
  <pre><code>object M extends Maker {
    val a = make
  }
  </code></pre>
  
  <p>But then, if I try this:</p>
  
  <pre><code>M.accept(M.a)
  </code></pre>
  
  <p>then I get a compile-time error:</p>
  
  <pre><code>type mismatch; found : com.test.Obj[object com.test.M] required: com.test.Obj[com.test.M.type]
  </code></pre>
  
  <p>My questions:</p>
  
  <ol>
  <li>What's the type <code>object com.test.M</code>, and how is it different from <code>com.test.M.type</code>?</li>
  <li>How can I do this in a smarter way?</li>
  </ol>