The help menu of the Scala compiler (2.9.2) says
-print Print program with Scala-specific features removed.
But the following call with the -print option shows Scala-specific features:
C:\Users\John\Test Scala Project\src\main\scala>type test.scala
trait A
C:\Users\John\Test Scala Project\src\main\scala>scalac -print test.scala
[[syntax trees at end of cleanup]]// Scala source: test.scala
package <empty> {
abstract trait A extends java.lang.Object
}
Why is the trait still shown ? I would have expected pure Java code.
The description is deceiving indeed, but it never said it would print Java code. It couldn’t do that anyway: Scala generates valid bytecode, but not bytecode that can be directly translated into Java.
What it does is generate code after the
cleanupphase. Now, if you try-Xshow-phaseson Scala 2.9.2, you’ll see this:Note that
cleanupis the last phase beforeicode, and that’s really the point. The parameter-printprints stuff after everything that changes the abstract syntax tree had a go at it. When the AST is about ready for code generation.