且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Scala中找到隐式的来源?

更新时间:2021-10-28 23:00:14

我这样做了(如迈克尔评论中所建议的那样):

I did this (as suggested in Michael's comment):

    import scala.reflect.runtime.universe.reify
    println(reify(entity(as[Question])))

打印:

Expr[spray.routing.Directive1[spray_examples.plain_rest.danielasfregola.quiz.management.entities.Question]](QuestionResource.entity(QuestionResource.as[Question](Deserializer.fromRequestUnmarshaller(Deserializer.fromMessageUnmarshaller(QuestionResource.json4sUnmarshaller(ManifestFactory.classType(classOf[spray_examples.plain_rest.danielasfregola.quiz.management.entities.Question])))))))

这直接告诉了隐式从哪里来:Deserializer.fromRequestUnmarshaller

This tells directly where the implicit is coming from : Deserializer.fromRequestUnmarshaller

此外,这是另一种方式,通过使用InteliJ的搜索使用功能:

Also, here is an other way, by using InteliJ's search usage function: