Skip to content

Commit f67e1c9

Browse files
oderskynicolasstucki
authored andcommitted
Rename tree -> rootTree
Rename `tree`, `trees` and associated methods in `ClassSymbol` to `rootTree`, `rootTrees`. We want to add another tree field to symbols that points directly to the symbol's definition tree. So we should be more specific about `rootTree`.
1 parent 999d1cb commit f67e1c9

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -942,20 +942,20 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
942942

943943
/** A trait for loaders that compute trees. Currently implemented just by DottyUnpickler. */
944944
trait TreeProvider {
945-
protected def computeTrees(implicit ctx: Context): List[Tree]
945+
protected def computeRootTrees(implicit ctx: Context): List[Tree]
946946

947947
private[this] var myTrees: List[Tree] = null
948948

949949
/** Get trees defined by this provider. Cache them if -Yretain-trees is set. */
950-
def trees(implicit ctx: Context): List[Tree] =
950+
def rootTrees(implicit ctx: Context): List[Tree] =
951951
if (ctx.settings.YretainTrees.value) {
952-
if (myTrees == null) myTrees = computeTrees
952+
if (myTrees == null) myTrees = computeRootTrees
953953
myTrees
954-
} else computeTrees
954+
} else computeRootTrees
955955

956956
/** Get first tree defined by this provider, or EmptyTree if none exists */
957957
def tree(implicit ctx: Context): Tree =
958-
trees.headOption.getOrElse(EmptyTree)
958+
rootTrees.headOption.getOrElse(EmptyTree)
959959

960960
/** Is it possible that the tree to load contains a definition of or reference to `id`? */
961961
def mightContain(id: String)(implicit ctx: Context) = true

compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ class ClassfileLoader(val classfile: AbstractFile) extends SymbolLoader {
382382
if (mayLoadTreesFromTasty) {
383383
result match {
384384
case Some(unpickler: tasty.DottyUnpickler) =>
385-
classRoot.classSymbol.treeOrProvider = unpickler
386-
moduleRoot.classSymbol.treeOrProvider = unpickler
385+
classRoot.classSymbol.rootTreeOrProvider = unpickler
386+
moduleRoot.classSymbol.rootTreeOrProvider = unpickler
387387
case _ =>
388388
}
389389
}

compiler/src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,13 +672,13 @@ object Symbols {
672672
* Returns the TypeDef tree (possibly wrapped inside PackageDefs) for this class, otherwise EmptyTree.
673673
* This will force the info of the class.
674674
*/
675-
def tree(implicit ctx: Context): Tree = treeContaining("")
675+
def rootTree(implicit ctx: Context): Tree = rootTreeContaining("")
676676

677677
/** Same as `tree` but load tree only if `id == ""` or the tree might contain `id`.
678678
* For Tasty trees this means consulting whether the name table defines `id`.
679679
* For already loaded trees, we maintain the referenced ids in an attachment.
680680
*/
681-
def treeContaining(id: String)(implicit ctx: Context): Tree = {
681+
def rootTreeContaining(id: String)(implicit ctx: Context): Tree = {
682682
denot.infoOrCompleter match {
683683
case _: NoCompleter =>
684684
case _ => denot.ensureCompleted()
@@ -696,9 +696,9 @@ object Symbols {
696696
}
697697
}
698698

699-
def treeOrProvider: TreeOrProvider = myTree
699+
def rootTreeOrProvider: TreeOrProvider = myTree
700700

701-
private[dotc] def treeOrProvider_=(t: TreeOrProvider)(implicit ctx: Context): Unit =
701+
private[dotc] def rootTreeOrProvider_=(t: TreeOrProvider)(implicit ctx: Context): Unit =
702702
myTree = t
703703

704704
private def mightContain(tree: Tree, id: String)(implicit ctx: Context): Boolean = {

compiler/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class DottyUnpickler(bytes: Array[Byte], mode: UnpickleMode = UnpickleMode.TopLe
6161
new TreeSectionUnpickler(posUnpicklerOpt, commentUnpicklerOpt)
6262
}
6363

64-
protected def computeTrees(implicit ctx: Context) = treeUnpickler.unpickle(mode)
64+
protected def computeRootTrees(implicit ctx: Context) = treeUnpickler.unpickle(mode)
6565

6666
private[this] var ids: Array[String] = null
6767

compiler/src/dotty/tools/dotc/fromtasty/ReadTastyTreesFromClasses.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ class ReadTastyTreesFromClasses extends FrontEnd {
3939

4040
def compilationUnit(cls: Symbol): Option[CompilationUnit] = cls match {
4141
case cls: ClassSymbol =>
42-
(cls.treeOrProvider: @unchecked) match {
42+
(cls.rootTreeOrProvider: @unchecked) match {
4343
case unpickler: tasty.DottyUnpickler =>
44-
if (cls.tree.isEmpty) None
44+
if (cls.rootTree.isEmpty) None
4545
else {
46-
val unit = mkCompilationUnit(cls, cls.tree, forceTrees = true)
46+
val unit = mkCompilationUnit(cls, cls.rootTree, forceTrees = true)
4747
unit.pickled += (cls -> unpickler.unpickler.bytes)
4848
Some(unit)
4949
}
@@ -64,7 +64,7 @@ class ReadTastyTreesFromClasses extends FrontEnd {
6464
case clsd: ClassDenotation =>
6565
clsd.infoOrCompleter match {
6666
case info: ClassfileLoader =>
67-
info.load(clsd) // sets cls.treeOrProvider and cls.moduleClass.treeProvider as a side-effect
67+
info.load(clsd) // sets cls.rootTreeOrProvider and cls.moduleClass.treeProvider as a side-effect
6868
case _ =>
6969
}
7070
def moduleClass = clsd.owner.info.member(className.moduleClassName).symbol

compiler/src/dotty/tools/dotc/interactive/SourceTree.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ object SourceTree {
5353
Some(SourceTree(tree, sourceFile))
5454
case _ => None
5555
}
56-
sourceTreeOfClass(sym.treeContaining(id))
56+
sourceTreeOfClass(sym.rootTreeContaining(id))
5757
}
5858
}
5959
}

compiler/src/dotty/tools/dotc/transform/Pickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class Pickler extends Phase {
103103
}
104104
pickling.println("************* entered toplevel ***********")
105105
for ((cls, unpickler) <- unpicklers) {
106-
val unpickled = unpickler.trees
106+
val unpickled = unpickler.rootTrees
107107
testSame(i"$unpickled%\n%", beforePickling(cls), cls)
108108
}
109109
}

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@ class Typer extends Namer
16161616
// check value class constraints
16171617
checkDerivedValueClass(cls, body1)
16181618

1619-
if (ctx.settings.YretainTrees.value) cls.treeOrProvider = cdef1
1619+
if (ctx.settings.YretainTrees.value) cls.rootTreeOrProvider = cdef1
16201620

16211621
cdef1
16221622

0 commit comments

Comments
 (0)