title: Nested trait in class constructor in scala
body: <p>I'm playing around with scala (scala 2.8).  Suppose I have a class with a nested trait, and want to use that nested trait as the type for a parameter in the class's constructor.  Is that even possible?  This is the closest I've come:</p>
  
  <pre><code>class OuterClass(traitParam:OuterClass#InnerTrait) {
    trait InnerTrait { }
    val y:InnerTrait = traitParam
  }
  </code></pre>
  
  <p>Without the third line that even compiles, but as soon as I try to actually use the <code>traitParam</code> as an <code>InnerTrait</code> I get a compiler error: </p>
  
  <blockquote>
    <p>type mismatch; found: OuterClass#InnerTrait required: OuterClass.this.InnerTrait.</p>
  </blockquote>
  
  <p>I can't figure out what (if anything) I could do.  Doing </p>
  
  <pre><code>class OuterClass(traitParam:OuterClass.this.InnerTrait)
  </code></pre>
  
  <p>instead, as the error message might suggest, does not compile.  Do I have any choice other than to move <code>InnerTrait</code> outside of <code>OuterClass</code>?  If you're wondering why I would want to do this, the answer is that in my actual code, the equivalent of <code>OuterClass</code> has type parameters which would then be used in <code>InnerTrait</code>.  If I move it outside, then I have to restate the type parameters every time I reference the inner trait.</p>