fork download
  1. object Main extends App {
  2. trait B[T]{ def mImpl(x: T) }
  3.  
  4. implicit def intB = new B[Int] { def mImpl(x: Int) { println("Int: " + x) }}
  5. implicit def defaultB[T] = new B[T] { def mImpl(x: T) { println("Default: " + x) }}
  6.  
  7. trait A { def m[T](x: T)(implicit b: B[T]) = b.mImpl(x) }
  8.  
  9. val a = new A {}
  10. a.m(1)
  11. a.m("1")
  12. }
Success #stdin #stdout 0.39s 382080KB
stdin
Standard input is empty
stdout
Int: 1
Default: 1