title: Case Class and Implicit Arguments and Pattern Matching
body: <p>I tried to combine implicit arguments with case classes, but I got stuck.</p>
  
  <pre><code>case class C(i: Int)(implicit b: Boolean)
  val c1 = C(1)(true)
  implicit val b = true
  val c2 = C(2)
  c1 match {
    case C(i)(b) =&gt; // doesn´t work
    case C(i,b)  =&gt; // doesn´t work
    case C(i)    =&gt; // works, but wanted: if (b) i else 0 
  }
  </code></pre>
  
  <p>According to the Scala Language Specification it´s due to the compiler generated extractor object for case classes: My implicit <code>Boolean</code> is not a member of the resulting case class, so it has to be in the second (implicit) argument list (that I can´t find in the companion object´s apply method, unfortunately): </p>
  
  <blockquote>
    <p>A case class definition of <code>c[tps](ps1 ). . .(psn)</code> with type parameters <code>tps</code> and value
    parameters <code>ps</code> implicitly generates an extractor object (§8.1.8) which is defined as
    follows:</p>
  </blockquote>
  
  <pre><code>object c {
    def apply[tps](ps1 ). . .(psn): c[tps] = new c[Ts](xs1 ). . .(xsn)
    def unapply[tps](x: c[tps]) =
      if (x eq null) scala.None
      else scala.Some(x.xs11, . . . , x.xs1k)
  }
  </code></pre>
  
  <p>How can I define a case class with members that are implicitly supplied at creation time?</p>