title: In scala, why this implicit parameter cannot be inferred from the same scope?
body: <p>I'm writing a simple Apache Spark utility that automatically creates an AccumulatorV2 based on provided initial value:</p>
  
  <pre><code>  import java.lang
  
    type Acc[T] = AccumulatorV2[T, T]
  
    implicit val long1: Long =&gt; Acc[lang.Long] = _ =&gt; new LongAccumulator()LongAccumulator()
  
    implicit def double1: Double =&gt; Acc[lang.Double] = _ =&gt; new DoubleAccumulator()
  
    def accumulator[T1, T2](
                             initialValue: T1,
                             name: String
                           )(implicit
                             canBuildFrom: T1 =&gt; Acc[T2],
                             converter: T1 =&gt; T2,
                             sc: SparkContext = SparkContext.getOrCreate()
                           ): Acc[T2] = {
  
      val acc: Acc[T2] = canBuildFrom(initialValue)
      acc.reset()
      acc.add(initialValue)
  
      sc.register(acc, name)
  
      acc
    }
  </code></pre>
  
  <p>The 2 implicit parameters: canBuildFrom and converter are supposed to be provided by implicit function and compiler predefined typecast respectively. However, when I tried to call it:</p>
  
  <pre><code>Metrics.accumulator(0L, "webDriverDispatched")
  </code></pre>
  
  <p>I got the following error information:</p>
  
  <pre><code>Error:(102, 84) No implicit view available from Long =&gt; com.tribbloids.spookystuff.Metrics.Acc[T2].
                            webDriverDispatched: Acc[lang.Long] = Metrics.accumulator(0L, "webDriverDispatched"),
  Error:(102, 84) not enough arguments for method accumulator: (implicit canBuildFrom: Long =&gt; com.tribbloids.spookystuff.Metrics.Acc[T2], implicit converter: Long =&gt; T2, implicit sc: org.apache.spark.SparkContext)com.tribbloids.spookystuff.Metrics.Acc[T2].
  Unspecified value parameters canBuildFrom, converter.
                            webDriverDispatched: Acc[lang.Long] = Metrics.accumulator(0L, "webDriverDispatched"),
  </code></pre>
  
  <p>Why scala compiler failed to find the right implicit value? And what should I do to fix it?</p>