显示Scala表达式的推断类型

Rob*_*een 9 eclipse scala sbt

如何查看Scala编译器为表达式等推断的类型?我有一些复杂的类型推断和隐式转换的代码,很难通过阅读代码看到发生了什么.

我试过添加

scalacOptions in Compile += "-Xprint-types"
Run Code Online (Sandbox Code Playgroud)

在build.sbt中,但这没有任何效果.

直接使用scalac并不是很吸引人,因为我有很多依赖项.

我使用Eclipse Scala插件和ENSIME编写代码,使用SBT构建.

Rob*_*een 5

它需要

scalacOptions in Compile ++= Seq("-Xprint-types", "-Xprint:typer")
Run Code Online (Sandbox Code Playgroud)

代替.

不幸的是输出不是很可读.:(


Rob*_*een 2

Eclipse Scala IDE 3.0 中已添加此功能!

选择代码的任意部分并按 Ctrl-Shift-W T(在 Mac 上将 Ctrl 替换为 Cmd)以查看推断的类型。