如何找到Scala隐式定义的位置?

编程入门 行业动态 更新时间:2024-10-26 04:22:12
本文介绍了如何找到Scala隐式定义的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个方法可以接受隐式参数,并且在代码中某处已定义了隐式值.但是我找不到我的代码在其中创建的位置.

I have a method that accepts an implicit parameter and somewhere in the code that implicit value has been defined. However I haven't been able to find where my code has created it.

有没有一种简单的方法来查找Scala中定义了隐式值的位置?到目前为止,我只是在扫描导入的源代码,但这非常繁琐.我正在使用IntelliJ.

Is there an easy way to find where an implicit value has been defined in Scala? So far I'm just scanning the source code of my imports but this is extremely tedious. I am using IntelliJ.

推荐答案

Intellij scala插件最近添加了可显式显示隐式特性的功能:)

Intellij scala plugin has recently added feature to display implicits explicitly :)

您可以按ctl+alt+shift+++键显示隐式内容.

You can press ctl+alt+shift+++ to display implicits.

或参考Travis Brown的答案此处. 他的回答中的小片段:

Or Refer answer from Travis Brown here. Small snippet from his answer :

scala> import scala.reflect.runtime.universe.reify import scala.reflect.runtime.universe.reify scala> reify("a" * 3).tree res6: reflect.runtime.universe.Tree = Predef.augmentString("a").$times(3)

更多推荐

如何找到Scala隐式定义的位置?

本文发布于:2023-11-10 22:51:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1576683.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:定义   位置   隐式   Scala

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!