Is there a systematic way to discover which implicit defs are in scope, and which one is bound at a particular point?

前端 未结 2 1405
感动是毒
感动是毒 2020-12-28 16:06

Often there\'s no need to pay any attention to implicit arguments in Scala, but sometimes it\'s very helpful to understand how the compiler is automatically providing them.

2条回答
  •  隐瞒了意图╮
    2020-12-28 16:34

    1. Add the option -Xprint:typer to the scalac command line. This prints the program tree just after the typer compiler phase. This works best with a short, self contained example. You can also pass this to scalac. This is a really huge step towards self-reliance in Scala!
    2. As mentioned by Randall, IntelliJ shows in-scope and the selected Implicit View with CTRL-ALT-SHIFT-I. Wait a month or two and implicit arguments are likely to have similar support.

提交回复
热议问题