Scala中的以下语句引发运行时错误:
val a = 10: Object
error: the result type of an implicit conversion must be more specific than Object
val a = 10: Object
^
如果Scala中不允许上述隐式转换,那么为什么Scala在编译时不抛出错误?
答案 0 :(得分:2)
您为什么认为这是运行时错误?不是:
$ scalac impl.scala
impl.scala:3: error: the result type of an implicit conversion must be more specific than Object
val a = 10: Object
^
one error found