score:0

You can suppress the default implicit conversion that is defined in the Predef:

import Predef.{long2Long=>_,println}

object Test{

  val tL : java.lang.Long = 1L

}

You'll then get a type error :

Error:(26, 29) type mismatch;
 found   : scala.Long(1L)
 required: java.lang.Long
  val tL : java.lang.Long = 1L
                        ^

But, in your case your parameters are getting boxed as an Any* (a wrapped array). The runtime boxed representation of a scala long is java.lang.Long. This isn't an implicit conversion, so it isn't going to be suppressed.

import Predef.{long2Long=>_,println}

object Test extends App{

   def a(params: Any*) = {
    for(p<-params) yield(p.getClass)
  }

  println(a(1L))

}

Output:

ArrayBuffer(class java.lang.Long)

Its possible you want to write generic code that avoids boxing. If thats the case you'll need to look into specialization.


Related Query

More Query from same tag