title: Problem with bounded type parameterised case class and default args in Scala
body: <p>Consider the following (tested with Scala 2.8.1 and 2.9.0):</p>
  
  <pre><code>trait Animal
  class Dog extends Animal
  
  case class AnimalsList[A &lt;: Animal](list:List[A] = List())
  case class AnimalsMap[A &lt;: Animal](map:Map[String,A] = Map())
  
  val dogList = AnimalsList[Dog]()  // Compiles
  val dogMap = AnimalsMap[Dog]()    // Does not compile
  </code></pre>
  
  <p>The last line fails with:</p>
  
  <pre><code>error: type mismatch;
   found   : scala.collection.immutable.Map[Nothing,Nothing]
   required: Map[String,Main.Dog]
  Note: Nothing &lt;: String, but trait Map is invariant in type A.
  You may wish to investigate a wildcard type such as `_ &lt;: String`. (SLS 3.2.10)
  Error occurred in an application involving default arguments.
      val dogMap = AnimalsMap[Dog]()    // Does not compile
                         ^
  one error found
  </code></pre>
  
  <p>Changing it to <code>val dogMap = AnimalsMap[Dog](Map())</code> fixes it, but no longer takes advantage of the default argument value.</p>
  
  <p>Why is the default value being inferred as Map[Nothing,Nothing], given that List counterpart works as expected? Is there a way to create an AnimalsMap instance that uses the default value for the <code>map</code> arg?</p>
  
  <hr>
  
  <p><strong>Edit:</strong> I've accepted an answer to my more-pressing second question, but I'd still be interested to know why the key type to <code>Map()</code> is inferred differently between these two cases:</p>
  
  <pre><code>case class AnimalsMap1(map:Map[String,Animal] = Map())
  val dogs1 = AnimalsMap1() // Compiles
  
  case class AnimalsMap2[A &lt;: Animal](map:Map[String,A] = Map())
  val dogs2 = AnimalsMap2[Dog]() // Does not compile
  </code></pre>
  
  <hr>
  
  <p><strong>Edit 2:</strong> Seems that type bounds are irrelevant - any parametric type to the case class causes the problem:</p>
  
  <pre><code>case class Map3[A](map:Map[String,A] = Map())
  val dogs3 = Map3[Dog]() // Does not compile
  </code></pre>