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 {
555555
556556 type ThisName = TypeName
557557
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.
578560 * This will force the info of the class.
579561 */
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 */ = {
581563 denot.info
582564 // TODO: Consider storing this tree like we store lazy trees for inline functions
583565 if (unpickler != null && ! denot.isAbsent) {
Original file line number Diff line number Diff line change @@ -43,13 +43,15 @@ object SourceTree {
4343 sym.sourceFile == null ) // FIXME: We cannot deal with external projects yet
4444 None
4545 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 =>
4850 val sourceFile = new SourceFile (sym.sourceFile, Codec .UTF8 )
4951 Some (SourceTree (tree, sourceFile))
50- case _ =>
51- None
52+ case _ => None
5253 }
54+ findTree(sym.tree)
5355 }
5456 }
5557}
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ object LinkAll {
6767
6868 private [LinkAll ] def loadCompilationUnit (clsd : ClassDenotation )(implicit ctx : Context ): Option [CompilationUnit ] = {
6969 assert(ctx.settings.XlinkOptimise .value)
70- val tree = clsd.symbol.asClass.unitTree
70+ val tree = clsd.symbol.asClass.tree
7171 if (tree.isEmpty) None
7272 else {
7373 ctx.log(" Loading compilation unit for: " + clsd)
You can’t perform that action at this time.
0 commit comments