title: overloading methods based on implicits
body: <p>i wrote this code</p>
  
  <pre><code>trait Pet
  case class Dog() extends Pet
  case class Cat() extends Pet
  def foo(i: Int)(implicit d: Dog) = println("dog")
  def foo(i: Int)(implicit c: Cat) = println("cat")
  def doFoo(a: Pet) = {
    a match {
      case a: Dog =&gt; implicit val dog : Dog = a; foo(10)
      case a: Cat =&gt; implicit val cat : Cat = a; foo(10)
      case _ =&gt; println("unknown")
    }
  }
  </code></pre>
  
  <p>I get an error</p>
  
  <pre><code>cmd0.sc:8: ambiguous reference to overloaded definition,
  both method foo in object cmd0 of type (i: Int)(implicit c: $sess.cmd0.Cat)Unit
  and  method foo in object cmd0 of type (i: Int)(implicit d: $sess.cmd0.Dog)Unit
  match argument types (Int)
      case a: Dog =&gt; implicit val dog : Dog = a; foo(10)
                                                 ^
  cmd0.sc:9: ambiguous reference to overloaded definition,
  both method foo in object cmd0 of type (i: Int)(implicit c: $sess.cmd0.Cat)Unit
  and  method foo in object cmd0 of type (i: Int)(implicit d: $sess.cmd0.Dog)Unit
  match argument types (Int)
      case a: Cat =&gt; implicit val cat : Cat = a; foo(10)
  </code></pre>
  
  <p>But why does it feel that there is ambiguity ... because in my first case match there is an implicit val dog and in my second case match there is an implicit val cat. So it should find the right implicits.</p>
  
  <p>why is it not resolving correctly?</p>
  
  <p>My environment is </p>
  
  <pre><code>Welcome to the Ammonite Repl 0.8.2
  (Scala 2.12.1 Java 1.8.0_121)
                                             ^
  </code></pre>