このコードがローカル スコープで定義された暗黙的な関数を使用しないのはなぜですか? これは他のどこから暗黙の関数を取得しますか?
def implctest[T](a: T)(implicit b:T=>T):T = {b apply a}
class Testimplcl(val a:Int){
override def toString() = "value of the 'a' is = "+a
}
implicit def dble(x: Int):Int = {x + x}
implicit def stringer(x: String):String = {x+" no not a pity"}
implicit def myclass(x: Testimplcl):Testimplcl = new Testimplcl(x.a +1)
implctest[String]("oh what a pity")
implctest[Int](5)
implctest[Testimplcl](new Testimplcl(4))
ローカル スコープの暗黙的な定義はどれも取り込まれません。たとえば、implctestInt が結果 5 を返す場合、dble を暗黙的として取得することで 10 が返されることを期待しています。
エラーも表示されません。implctest は、渡された引数を返すだけです。