Skip to content

Instantly share code, notes, and snippets.

@retronym
Created July 24, 2018 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retronym/815c16eb7c2538ff2ba9d7508670bbc9 to your computer and use it in GitHub Desktop.
Save retronym/815c16eb7c2538ff2ba9d7508670bbc9 to your computer and use it in GitHub Desktop.
$ cat sandbox/test.scala; scalac -Yshow-trees -Xprint:typer sandbox/test.scala
trait T {
private[this] var foo = 42;
}
class C {
private[this] var foo = 42;
}
[[syntax trees at end of typer]]// Scala source: test.scala
PackageDef(
"<empty>" // final package <empty>, tree.tpe=<empty>.type
ClassDef( // abstract trait T extends AnyRef
abstract <defaultparam/trait>
"T"
[]
Template( // val <local T>: <notype> in trait T, tree.tpe=T
"java.lang.Object" // parents
ValDef(
private
"_"
<tpt>
<empty>
)
// 3 statements
DefDef( // def $init$(): Unit in trait T
<method>
"$init$"
[]
List(Nil)
<tpt> // tree.tpe=Unit
Block( // tree.tpe=Unit
{}
()
)
)
ValDef( // private[this] def foo: Int in trait T
<method> private <mutable> <local> <accessor>
"foo"
<tpt> // tree.tpe=Int
42
)
DefDef( // private[this] def foo_=(x$1: Int): Unit in trait T
<method> private <local> <accessor>
"foo_$eq"
[]
// 1 parameter list
ValDef( // x$1: Int
<param> <synthetic>
"x$1"
<tpt> // tree.tpe=Int
<empty>
)
<tpt> // tree.tpe=Unit
<empty>
)
)
)
ClassDef( // class C extends AnyRef
0
"C"
[]
Template( // val <local C>: <notype> in class C, tree.tpe=C
"java.lang.Object" // parents
ValDef(
private
"_"
<tpt>
<empty>
)
// 2 statements
DefDef( // def <init>(): C in class C
<method>
"<init>"
[]
List(Nil)
<tpt> // tree.tpe=C
Block( // tree.tpe=Unit
Apply( // def <init>(): Object in class Object, tree.tpe=Object
C.super."<init>" // def <init>(): Object in class Object, tree.tpe=()Object
Nil
)
()
)
)
ValDef( // private[this] var foo: Int in class C
private <mutable> <local>
"foo"
<tpt> // tree.tpe=Int
42
)
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment