Skip to content

Commit a1bff5f

Browse files
committed
Make TreeTypeMap non-final
We'll need to create a subclass in order to support substitutions with holes. To enable this, add a method `newMap` that creates a tree map of the same kind as the current one.
1 parent 376d325 commit a1bff5f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import dotty.tools.dotc.transform.SymUtils._
3131
* gets two different denotations in the same period. Hence, if -Yno-double-bindings is
3232
* set, we would get a data race assertion error.
3333
*/
34-
final class TreeTypeMap(
34+
class TreeTypeMap(
3535
val typeMap: Type => Type = IdentityTypeMap,
3636
val treeMap: tpd.Tree => tpd.Tree = identity _,
3737
val oldOwners: List[Symbol] = Nil,
@@ -154,7 +154,7 @@ final class TreeTypeMap(
154154
assert(!to.exists(substFrom contains _))
155155
assert(!from.exists(newOwners contains _))
156156
assert(!to.exists(oldOwners contains _))
157-
new TreeTypeMap(
157+
newMap(
158158
typeMap,
159159
treeMap,
160160
from ++ oldOwners,
@@ -163,6 +163,16 @@ final class TreeTypeMap(
163163
to ++ substTo)
164164
}
165165

166+
/** A new map of the same class this one */
167+
protected def newMap(
168+
typeMap: Type => Type,
169+
treeMap: Tree => Tree,
170+
oldOwners: List[Symbol],
171+
newOwners: List[Symbol],
172+
substFrom: List[Symbol],
173+
substTo: List[Symbol])(implicit ctx: Context) =
174+
new TreeTypeMap(typeMap, treeMap, oldOwners, newOwners, substFrom, substTo)
175+
166176
/** Apply `typeMap` and `ownerMap` to given symbols `syms`
167177
* and return a treemap that contains the substitution
168178
* between original and mapped symbols.

0 commit comments

Comments
 (0)