Suppose the following is in the source file called Something.scala
:
object Something { val x = "foo".charAt(0) }
You can use the -Xprint:typer
compiler flag to see the program after the typer
compiler typer
:
$ scalac -Xprint:typer Something.scala [[syntax trees at end of typer]]// Scala source: Something.scala package <empty> { final object Something extends java.lang.Object with ScalaObject { def this(): object Something = { Something.super.this(); () }; private[this] val x: Char = "foo".charAt(0); <stable> <accessor> def x: Char = Something.this.x } }
You can also use :type
in REPL:
scala> :type "foo".charAt(0) Char scala> :type "foo".charAt _ Int => Char
Your IDE may also provide a more convenient way to get this information, as Luigi Pling notes in the comment above.
source share