title: Struggling with ambigous types in scala
body: <p>I am really struggling with ambigous types in scala...</p>
  
  <p>I want to implement a StackManager which holds multiple stacks with different types... But something seems to be wrong.</p>
  
  <pre><code>object StackManager {
  
    val stacks = mutable.HashMap[String, mutable.Stack[_]]()
    def get[T](id: String): mutable.Stack[T] = {
      stacks.get(id) match {
        case Some(stack: mutable.Stack[T]) =&gt; stack
        case None =&gt; {
          val newStack = mutable.Stack[T]()
          stacks.put(id, newStack)
          newStack
        }
      }
    }
    def set[T](id: String, stack: mutable.Stack[T]) {
      stacks.put(id, stack)
    }
  }
  </code></pre>
  
  <p>EDIT: With that I want to store different types of stacks in my manager:</p>
  
  <pre><code>StackManager.set[ClassA]("stack01", new mutable.Stack[ClassA]())
  StackManager.set[ClassB]("stack02", new mutable.Stack[ClassB]())
  
  StackManager.get[ClassA]("stack01") // returns the stack with type mutable.Stack[ClassA]
  StackManager.get[ClassB]("stack02") // returns the stack with type mutable.Stack[ClassB]
  </code></pre>
  
  <p>EDIT2: scala version 2.9.2</p>