Skip to content

Commit 9aefa10

Browse files
committed
Apply @transientParam to compiler
It's very important that tree nodes don't capture contexts. The @transientParam annotation makes sure they don't.
1 parent 5c7c94a commit 9aefa10

File tree

6 files changed

+99
-94
lines changed

6 files changed

+99
-94
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import util.Property
1212
import collection.mutable.ListBuffer
1313
import reporting.diagnostic.messages._
1414
import reporting.trace
15+
import annotation.transientParam
1516

1617
import scala.annotation.internal.sharable
1718

@@ -42,23 +43,23 @@ object desugar {
4243

4344
// ----- DerivedTypeTrees -----------------------------------
4445

45-
class SetterParamTree(implicit ids: TreeIds) extends DerivedTypeTree {
46+
class SetterParamTree(implicit @transientParam ids: TreeIds) extends DerivedTypeTree {
4647
def derivedTree(sym: Symbol)(implicit ctx: Context): tpd.TypeTree = tpd.TypeTree(sym.info.resultType)
4748
}
4849

49-
class TypeRefTree(implicit ids: TreeIds) extends DerivedTypeTree {
50+
class TypeRefTree(implicit @transientParam ids: TreeIds) extends DerivedTypeTree {
5051
def derivedTree(sym: Symbol)(implicit ctx: Context): tpd.TypeTree = tpd.TypeTree(sym.typeRef)
5152
}
5253

53-
class TermRefTree(implicit ids: TreeIds) extends DerivedTypeTree {
54+
class TermRefTree(implicit @transientParam ids: TreeIds) extends DerivedTypeTree {
5455
def derivedTree(sym: Symbol)(implicit ctx: Context): tpd.Tree = tpd.ref(sym)
5556
}
5657

5758
/** A type tree that computes its type from an existing parameter.
5859
* @param suffix String difference between existing parameter (call it `P`) and parameter owning the
5960
* DerivedTypeTree (call it `O`). We have: `O.name == P.name + suffix`.
6061
*/
61-
class DerivedFromParamTree(suffix: String)(implicit ids: TreeIds) extends DerivedTypeTree {
62+
class DerivedFromParamTree(suffix: String)(implicit @transientParam ids: TreeIds) extends DerivedTypeTree {
6263

6364
/** Make sure that for all enclosing module classes their companion classes
6465
* are completed. Reason: We need the constructor of such companion classes to
@@ -1388,6 +1389,6 @@ object desugar {
13881389
buf.toList
13891390
}
13901391

1391-
private class IrrefutableGenFrom(pat: Tree, expr: Tree)(implicit ids: TreeIds)
1392+
private class IrrefutableGenFrom(pat: Tree, expr: Tree)(implicit @transientParam ids: TreeIds)
13921393
extends GenFrom(pat, expr)
13931394
}

0 commit comments

Comments
 (0)