title: Why is this call to implicitly ambiguous?
body: <p>The signature of the <code>sum</code> method on <code>TraversableOnce</code> is as follows:</p>
  
  <pre><code>def sum[B &gt;: A](implicit num: Numeric[B]): B = foldLeft(num.zero)(num.plus)
  </code></pre>
  
  <p>I can use it thus:</p>
  
  <pre><code>scala&gt; (1 to 10).sum
  res0: Int = 55
  </code></pre>
  
  <p>In this case, the compiler is injecting the <code>Numeric[B]</code> itself, so there must be an unambiguous implicit value of this type in scope. If I use <code>Predef.implicitly</code> to inject it myself, this happens:</p>
  
  <pre><code>scala&gt; (1 to 10).sum(implicitly)
  &lt;console&gt;:6: error: ambiguous implicit values:
   both method conforms in object Predef of type [A]&lt;:&lt;[A,A]
   and method stringCanBuildFrom in object Predef of type =&gt; scala.collection.generic.CanBuildFrom[String,Char,String]
   match expected type T
     (1 to 10).sum(implicitly)
                   ^
  </code></pre>
  
  <p><strong>Why is this ambiguous?</strong> </p>
  
  <p><em>I can make the ambiguity disappear either by</em></p>
  
  <pre><code>scala&gt; (1 to 10).sum(implicitly[Numeric[Int]])
  res2: Int = 55
  </code></pre>
  
  <p><em>Or</em></p>
  
  <pre><code>scala&gt; (1 to 10).sum[Int](implicitly)
  res3: Int = 55
  </code></pre>
  
  <p>I presume that this has something to do with the fact that sum declares a new type parameter <code>B &gt;: A</code> (<em>it clearly is, see below edit</em>), but I'm still confused about why something can be unambiguously found in the first example but not the second?</p>
  
  <p><strong>EDIT</strong> - <em>to address subsub's inane comment (below)</em></p>
  
  <pre><code>scala&gt; class As[A](as : A*) { 
   | def sum(implicit num : Numeric[A]) : A = as.foldLeft(num.zero)(num.plus) 
   | }
  defined class As
  
  scala&gt; (new As(1, 2, 3, 4)).sum
  res0: Int = 10
  
  scala&gt; (new As(1, 2, 3, 4)).sum(implicitly)
  res1: Int = 10
  </code></pre>
  
  <p><em>So, you can see that it is not the case that any call to implicitly is ambiguous</em></p>