title: Map with path-dependent value type?
body: <p>I know that Scala has path-dependent types, so for example if I have a class within an inner class I can constrain one argument of a method to be an instance of the inner class of the other argument:</p>
  
  <pre><code>class Outer { class Inner( x:Int ) }
  val o1 = new Outer
  val o2 = new Outer
  val i11 = new o1.Inner(11)
  val i12 = new o1.Inner(12)
  val i21 = new o2.Inner(21)
  def f[ A &lt;: Outer ]( a:A )( i:a.Inner ) = (a,i)
  f(o1)(i11)  // works
  f(o1)(i21)  // type mismatch; i21 is from o2, not o1
  </code></pre>
  
  <p>And I can create a Map from an Outer to an Inner using a type projection:</p>
  
  <pre><code>var m = Map[Outer,Outer#Inner]()
  </code></pre>
  
  <p>But that would allow entries like <code>o1 -&gt; i21</code>, and I don't want that to be allowed. Is there any type magic to require that a value be an instance of its key's inner class? That is, I want to say something like</p>
  
  <pre><code>var m = Map[Outer,$1.Inner]()  // this doesn't work, of course
  </code></pre>