@@ -22,8 +22,6 @@ import core.tasty.TreePickler.Hole
22
22
* @param newOwners New owners, replacing previous owners.
23
23
* @param substFrom The symbols that need to be substituted.
24
24
* @param substTo The substitution targets.
25
- * @param stopAtInlinedArgument Whether one should stop at an inlined argument,
26
- * i.e. a node of form Inlined(EmptyTree, _, _).
27
25
*
28
26
* The reason the substitution is broken out from the rest of the type map is
29
27
* that all symbols have to be substituted at the same time. If we do not do this,
@@ -33,21 +31,25 @@ import core.tasty.TreePickler.Hole
33
31
* do S2 we get outer#2.inner#4. But that means that the named type outer#2.inner
34
32
* gets two different denotations in the same period. Hence, if -Yno-double-bindings is
35
33
* set, we would get a data race assertion error.
36
- *
37
- * Note: TreeTypeMap is final, since derived maps are created dynamically for
38
- * nested scopes. Any subclass of TreeTypeMap would revert to the standard
39
- * TreeTypeMap in these recursive invocations.
40
34
*/
41
- final class TreeTypeMap (
35
+ class TreeTypeMap (
42
36
val typeMap : Type => Type = IdentityTypeMap ,
43
37
val treeMap : tpd.Tree => tpd.Tree = identity _,
44
38
val oldOwners : List [Symbol ] = Nil ,
45
39
val newOwners : List [Symbol ] = Nil ,
46
40
val substFrom : List [Symbol ] = Nil ,
47
- val substTo : List [Symbol ] = Nil ,
48
- stopAtInlinedArgument : Boolean = false )(using Context ) extends tpd.TreeMap {
41
+ val substTo : List [Symbol ] = Nil )(using Context ) extends tpd.TreeMap {
49
42
import tpd ._
50
43
44
+ def copy (
45
+ typeMap : Type => Type ,
46
+ treeMap : tpd.Tree => tpd.Tree ,
47
+ oldOwners : List [Symbol ],
48
+ newOwners : List [Symbol ],
49
+ substFrom : List [Symbol ],
50
+ substTo : List [Symbol ])(using Context ): TreeTypeMap =
51
+ new TreeTypeMap (typeMap, treeMap, oldOwners, newOwners, substFrom, substTo)
52
+
51
53
/** If `sym` is one of `oldOwners`, replace by corresponding symbol in `newOwners` */
52
54
def mapOwner (sym : Symbol ): Symbol = sym.subst(oldOwners, newOwners)
53
55
@@ -119,15 +121,8 @@ final class TreeTypeMap(
119
121
val (tmap1, stats1) = transformDefs(stats)
120
122
val expr1 = tmap1.transform(expr)
121
123
cpy.Block (blk)(stats1, expr1)
122
- case inlined @ Inlined (call, bindings, expanded) =>
123
- if stopAtInlinedArgument && call.isEmpty then
124
- expanded match
125
- case expanded : TypeTree => assert(bindings.isEmpty); expanded
126
- case _ => inlined
127
- else
128
- val (tmap1, bindings1) = transformDefs(bindings)
129
- val expanded1 = tmap1.transform(expanded)
130
- cpy.Inlined (inlined)(call, bindings1, expanded1)
124
+ case inlined : Inlined =>
125
+ transformInlined(inlined)
131
126
case cdef @ CaseDef (pat, guard, rhs) =>
132
127
val tmap = withMappedSyms(patVars(pat))
133
128
val pat1 = tmap.transform(pat)
@@ -183,14 +178,13 @@ final class TreeTypeMap(
183
178
assert(! to.exists(substFrom contains _))
184
179
assert(! from.exists(newOwners contains _))
185
180
assert(! to.exists(oldOwners contains _))
186
- new TreeTypeMap (
181
+ copy (
187
182
typeMap,
188
183
treeMap,
189
184
from ++ oldOwners,
190
185
to ++ newOwners,
191
186
from ++ substFrom,
192
- to ++ substTo,
193
- stopAtInlinedArgument)
187
+ to ++ substTo)
194
188
}
195
189
196
190
/** Apply `typeMap` and `ownerMap` to given symbols `syms`
0 commit comments