0
В Scala, благодаря аннотации annotation.implicitNotFound
, мы можем настроить сообщение об ошибке компилятора, когда неявный не найден.Inheriting implicitNotFound messages в Scala
Есть ли способ для производных классов как-то наследовать это сообщение implicitNotFound
? I.e., что-то вроде этого:
scala> import annotation.implicitNotFound
import annotation.implicitNotFound
scala> @implicitNotFound("custom message") trait Base[T]
defined trait Base
scala> trait Derived[T] extends Base[T]
defined trait Derived
scala> implicitly[Base[Int]]
<console>:13: error: custom message
implicitly[Base[Int]] // my message above, cool
^
scala> implicitly[Derived[Int]]
<console>:14: error: could not find implicit value for parameter e: Derived[Int]
implicitly[Derived[Int]] // not my message