File tree Expand file tree Collapse file tree 2 files changed +13
-27
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +13
-27
lines changed Original file line number Diff line number Diff line change @@ -70,11 +70,10 @@ object Splicer {
70
70
def checkEscapedVariables (tree : Tree , expansionOwner : Symbol )(given ctx : Context ): tree.type =
71
71
new TreeTraverser {
72
72
private [this ] var locals = Set .empty[Symbol ]
73
+ private def markSymbol (sym : Symbol )(implicit ctx : Context ): Unit =
74
+ locals = locals + sym
73
75
private def markDef (tree : Tree )(implicit ctx : Context ): Unit = tree match {
74
- case tree : DefTree =>
75
- val sym = tree.symbol
76
- if (! locals.contains(sym))
77
- locals = locals + sym
76
+ case tree : DefTree => markSymbol(tree.symbol)
78
77
case _ =>
79
78
}
80
79
def traverse (tree : Tree )(given ctx : Context ): Unit =
@@ -91,13 +90,7 @@ object Splicer {
91
90
traverseOver(last)
92
91
case CaseDef (pat, guard, body) =>
93
92
val last = locals
94
- // mark all bindings
95
- new TreeTraverser {
96
- def traverse (tree : Tree )(implicit ctx : Context ): Unit = {
97
- markDef(tree)
98
- traverseChildren(tree)
99
- }
100
- }.traverse(pat)
93
+ tpd.patVars(pat).foreach(markSymbol)
101
94
traverseOver(last)
102
95
case _ =>
103
96
markDef(tree)
Original file line number Diff line number Diff line change @@ -47,14 +47,16 @@ abstract class TreeMapWithStages(@constructorOnly ictx: Context) extends TreeMap
47
47
/** Localy defined symbols seen so far by `StagingTransformer.transform` */
48
48
protected def localSymbols : List [Symbol ] = enteredSyms
49
49
50
+ /** Enter staging level of symbol defined by `tree`, if applicable. */
51
+ private def markSymbol (sym : Symbol )(implicit ctx : Context ): Unit =
52
+ if ((sym.isClass || sym.maybeOwner.isTerm) && ! levelOfMap.contains(sym)) {
53
+ levelOfMap(sym) = level
54
+ enteredSyms = sym :: enteredSyms
55
+ }
56
+
50
57
/** Enter staging level of symbol defined by `tree`, if applicable. */
51
58
private def markDef (tree : Tree )(implicit ctx : Context ): Unit = tree match {
52
- case tree : DefTree =>
53
- val sym = tree.symbol
54
- if ((sym.isClass || sym.maybeOwner.isTerm) && ! levelOfMap.contains(sym)) {
55
- levelOfMap(sym) = level
56
- enteredSyms = sym :: enteredSyms
57
- }
59
+ case tree : DefTree => markSymbol(tree.symbol)
58
60
case _ =>
59
61
}
60
62
@@ -106,16 +108,7 @@ abstract class TreeMapWithStages(@constructorOnly ictx: Context) extends TreeMap
106
108
107
109
case CaseDef (pat, guard, body) =>
108
110
val last = enteredSyms
109
- // mark all bindings
110
- new TreeTraverser {
111
- def traverse (tree : Tree )(implicit ctx : Context ): Unit = tree match {
112
- case Quoted (t) => traverse(t)(quoteContext)
113
- case Splice (t) => traverse(t)(spliceContext)
114
- case _ =>
115
- markDef(tree)
116
- traverseChildren(tree)
117
- }
118
- }.traverse(pat)
111
+ tpd.patVars(pat).foreach(markSymbol)
119
112
mapOverTree(last)
120
113
121
114
case _ : Import =>
You can’t perform that action at this time.
0 commit comments