title: Ambiguous implicit values when using a generic method with an implicit parameter
body: <p>In the following code:</p>
  
  <pre><code>trait Foo[T] {
    def get: T
  }
  implicit object FooInt extends Foo[Int] {
    override def get = 0
  }
  implicit object FooString extends Foo[String] {
    override def get = "0"
  }
  def fooImplicitGetter[T](implicit ev: Foo[T]): T = ev.get
  
  val x: Int = fooImplicitGetter // Does not compile; ambiguous implicit values error
  
  
  implicit val int = 0
  implicit val string = ""
  def implicitGetter[T](implicit ev: T): T = ev
  
  val y: Int = implicitGetter // Compiles just fine
  </code></pre>
  
  <p>In the assignment of <code>x</code>, why can't the compiler infer that the type of fooImplicitGetter is <code>Int</code>, and therefore it needs to use the <code>FooInt</code> instance, as it can in the assignment of <code>y</code>? Is there any way of helping it other than <code>fooImplicitGetter[Int]</code>, passing <code>FooInt</code> explicitly, etc.? This is under 2.11 if it matter.</p>
  
  <p>EDIT: This appears to be the same issue mentioned here: <a href="https://stackoverflow.com/questions/36388954/inferring-type-of-generic-implicit-parameter-from-return-type">Inferring type of generic implicit parameter from return type</a>, so I've modified my example to match. I'm also fine with closing it for duplication, unless someone has an answer.</p>