What are <stable> and <accessor> when running Scalac -Xprint: typer?
I wrote a little bit of Scala
object SquareNumbers extends App { val numbers = List(1,2,3,4,5) val squares = numbers map (i => i * i) println (squares) } And run it through scalac like this:
$ scalac -Xprint:typer SquareNumbers.scala [[syntax trees at end of typer]] // SquareNumbers.scala package <empty> { object SquareNumbers extends Object with App { def <init>(): SquareNumbers.type = { SquareNumbers.super.<init>(); () }; private[this] val numbers: List[Int] = immutable.this.List.apply[Int](1, 2, 3, 4, 5); <stable> <accessor> def numbers: List[Int] = SquareNumbers.this.numbers; private[this] val squares: List[Int] = SquareNumbers.this.numbers.map[Int, List[Int]](((i: Int) => i.*(i)))(immutable.this.List.canBuildFrom[Int]); <stable> <accessor> def squares: List[Int] = SquareNumbers.this.squares; scala.this.Predef.println(SquareNumbers.this.squares) } } My question is: what is <stable> and <accessor> in the output? What are they called (like, they have a collective noun), and what do they do?
Under the assumption, I would say that this meant that they were vals instead of vars, and mean that it caused due to the object ...
These are internal (i.e., reflections 2.10 that are not displayed through the new APIs). The official compiler ScalaDoc site does not seem to work, but you can see the Scala source for more details :
final val STABLE = 1 << 22 // functions that are assumed to be stable // (typically, access methods for valdefs) // or classes that do not contain abstract types. And :
final val ACCESSOR = 1 << 27 // a value or variable accessor (getter or setter) Later in this file you can find a mapping between identifiers (for example, STABLE ) and printed lines ( <stable> ), lists of which are displayed on which phases, etc.