Skip to content

Commit 7c0e5e9

Browse files
committed
Don't force annotations on cleanup
Lazy annotations need not be forced when cleaning up since any future evaluation wil be in a future context, so they cannot contain dangling completers.
1 parent cb2e52f commit 7c0e5e9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,29 @@ object Annotations {
1010

1111
abstract class Annotation {
1212
def tree(implicit ctx: Context): Tree
13+
1314
def symbol(implicit ctx: Context): Symbol =
1415
if (tree.symbol.isConstructor) tree.symbol.owner
1516
else tree.tpe.typeSymbol
17+
1618
def matches(cls: Symbol)(implicit ctx: Context): Boolean = symbol.derivesFrom(cls)
19+
1720
def appliesToModule: Boolean = true // for now; see remark in SymDenotations
1821

1922
def derivedAnnotation(tree: Tree)(implicit ctx: Context) =
2023
if (tree eq this.tree) this else Annotation(tree)
2124

2225
def arguments(implicit ctx: Context) = ast.tpd.arguments(tree)
26+
2327
def argument(i: Int)(implicit ctx: Context): Option[Tree] = {
2428
val args = arguments
2529
if (i < args.length) Some(args(i)) else None
2630
}
2731
def argumentConstant(i: Int)(implicit ctx: Context): Option[Constant] =
2832
for (ConstantType(c) <- argument(i) map (_.tpe)) yield c
2933

34+
def isEvaluated: Boolean = true
35+
3036
def ensureCompleted(implicit ctx: Context): Unit = tree
3137
}
3238

@@ -43,6 +49,8 @@ object Annotations {
4349
if (myTree == null) myTree = complete(ctx)
4450
myTree
4551
}
52+
53+
override def isEvaluated = myTree != null
4654
}
4755

4856
/** An annotation indicating the body of a right-hand side,
@@ -73,7 +81,7 @@ object Annotations {
7381
}
7482
myBody
7583
}
76-
def isEvaluated = evaluated
84+
override def isEvaluated = evaluated
7785
}
7886

7987
object Annotation {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class InteractiveDriver(settings: List[String]) extends Driver {
200200
* trees are not cleand twice.
201201
* TODO: Find a less expensive way to check for those cycles.
202202
*/
203-
if (!seen(annot.tree))
203+
if (annot.isEvaluated && !seen(annot.tree))
204204
cleanupTree(annot.tree)
205205
}
206206
}

0 commit comments

Comments
 (0)