File tree Expand file tree Collapse file tree 3 files changed +10
-26
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +10
-26
lines changed Original file line number Diff line number Diff line change @@ -555,29 +555,11 @@ object Symbols {
555
555
556
556
type ThisName = TypeName
557
557
558
- /** If this is a top-level class, and if `-Yretain-trees` is set, return the TypeDef tree
559
- * for this class, otherwise EmptyTree. This will force the info of the class.
560
- */
561
- def tree (implicit ctx : Context ): tpd.Tree /* tpd.TypeDef | tpd.EmptyTree */ = {
562
- import ast .Trees ._
563
- def findTree (tree : tpd.Tree ): Option [tpd.TypeDef ] = tree match {
564
- case PackageDef (_, stats) =>
565
- stats.flatMap(findTree).headOption
566
- case tree : tpd.TypeDef if tree.symbol == this =>
567
- Some (tree)
568
- case _ =>
569
- None
570
- }
571
- val t = unitTree
572
- if (t.isEmpty) t
573
- else findTree(tree).get
574
- }
575
-
576
- /** If this is a top-level class, and if `-Yretain-trees` or `-YlinkOptimise` is set,
577
- * return the PackageDef tree for this class, otherwise EmptyTree.
558
+ /** If this is a top-level class, and if `-Yretain-trees` or `-Xlink-optimise` is set,
559
+ * return the TypeDef tree (possibly wrapped inside PackageDefs) for this class, otherwise EmptyTree.
578
560
* This will force the info of the class.
579
561
*/
580
- def unitTree (implicit ctx : Context ): tpd.Tree /* tpd.PackageDef | tpd.TypeDef | tpd.EmptyTree */ = {
562
+ def tree (implicit ctx : Context ): tpd.Tree /* tpd.PackageDef | tpd.TypeDef | tpd.EmptyTree */ = {
581
563
denot.info
582
564
// TODO: Consider storing this tree like we store lazy trees for inline functions
583
565
if (unpickler != null && ! denot.isAbsent) {
Original file line number Diff line number Diff line change @@ -43,13 +43,15 @@ object SourceTree {
43
43
sym.sourceFile == null ) // FIXME: We cannot deal with external projects yet
44
44
None
45
45
else {
46
- sym.tree match {
47
- case tree : tpd.TypeDef =>
46
+ import ast .Trees ._
47
+ def findTree (tree : tpd.Tree ): Option [SourceTree ] = tree match {
48
+ case PackageDef (_, stats) => stats.flatMap(findTree).headOption
49
+ case tree : tpd.TypeDef if tree.symbol == sym =>
48
50
val sourceFile = new SourceFile (sym.sourceFile, Codec .UTF8 )
49
51
Some (SourceTree (tree, sourceFile))
50
- case _ =>
51
- None
52
+ case _ => None
52
53
}
54
+ findTree(sym.tree)
53
55
}
54
56
}
55
57
}
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ object LinkAll {
67
67
68
68
private [LinkAll ] def loadCompilationUnit (clsd : ClassDenotation )(implicit ctx : Context ): Option [CompilationUnit ] = {
69
69
assert(ctx.settings.XlinkOptimise .value)
70
- val tree = clsd.symbol.asClass.unitTree
70
+ val tree = clsd.symbol.asClass.tree
71
71
if (tree.isEmpty) None
72
72
else {
73
73
ctx.log(" Loading compilation unit for: " + clsd)
You can’t perform that action at this time.
0 commit comments