title: Scala - handling "multiple overloaded alternatives of method ... define default arguments"
body: <p>Let's say I have a setting such as this:</p>
  
  <pre><code>sealed trait Annotation {
      def notes : Seq[String]
  }
  
  trait Something extends Annotation{
      //do something funny
  }
  
  case class A(val i:Int)(val notes:Seq[String] = Nil) extends Something
  object A{
      def apply(a:A)(notes:Seq[String] = Nil):A = A(a.i)(notes)
  }
  
  case class B(val b:Boolean)(val notes:Seq[String] = Nil) extends Something
  object B{
      def apply(b:B)(notes:Seq[String] = Nil):B = B(b.b)(notes)
  }
  
  case class C(val s:String)(val notes:Seq[String] = Nil) extends Something
  object C{
      def apply(c:C)(notes:Seq[String] = Nil) :C = C(c.s)(notes)
  }
  </code></pre>
  
  <p>Trying to <a href="http://ideone.com/8HO0Bx" rel="nofollow noreferrer">compile</a> this will result in</p>
  
  <pre><code>Main.scala:10: error: in object A, multiple overloaded alternatives of method apply define
  default arguments.
  object A{
         ^
  
  Main.scala:15: error: in object B, multiple overloaded alternatives of method apply define
  default arguments.
  object B{
         ^
  
  Main.scala:20: error: in object C, multiple overloaded alternatives of method apply define
  default arguments.
  object C{
         ^
  three errors found
  </code></pre>
  
  <p>I have read <a href="https://stackoverflow.com/questions/4652095/why-does-the-scala-compiler-disallow-overloaded-methods-with-default-arguments">this</a>, so I do at least have an idea as to why this is happening, what I don't know, however, is how I am supposed to resolve the issue.</p>
  
  <p>One possibility would - of course - be to simply omit the default values and force the client to provide Nil when no notes are to be stored, but is there a better solution? </p>