【发布时间】:2017-08-23 13:36:59
【问题描述】:
定义
type TA[T] = T => Int
implicit class TAOps[T](a: TA[T]) {
def foo(): Unit = {println("TA")}
}
val ta: TA[Double] = x => x.toInt
现在,
ta.foo()
编译失败,提示value foo is not a member of ammonite.$sess.cmd1.TA[Double],
当显式调用时
TAOps(ta).foo()
打印TA。为什么隐式转换在前一种情况下不起作用?
【问题讨论】:
标签: scala type-alias implicits