Skip to content

Commit 736dceb

Browse files
committed
Made FullParameterization more customizable
Can now decide on rewiring on a node-by-nide basis.
1 parent 491e076 commit 736dceb

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/dotty/tools/dotc/transform/FullParameterization.scala

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,22 @@ trait FullParameterization {
5252

5353
import tpd._
5454

55-
/** If references to original `target` from fully parameterized method `derived` should be
56-
* rewired to some fully parameterized method, that method symbol,
55+
/** If references to original symbol `referenced` from within fully parameterized method
56+
* `derived` should be rewired to some fully parameterized method, the rewiring target symbol,
5757
* otherwise NoSymbol.
5858
*/
59-
protected def rewiredTarget(target: Symbol, derived: Symbol)(implicit ctx: Context): Symbol
59+
protected def rewiredTarget(referenced: Symbol, derived: Symbol)(implicit ctx: Context): Symbol
60+
61+
/** If references to some original symbol from given tree node within fully parameterized method
62+
* `derived` should be rewired to some fully parameterized method, the rewiring target symbol,
63+
* otherwise NoSymbol. By default implemented as
64+
*
65+
* rewiredTarget(tree.symbol, derived)
66+
*
67+
* but can be overridden.
68+
*/
69+
protected def rewiredTarget(tree: Tree, derived: Symbol)(implicit ctx: Context): Symbol =
70+
rewiredTarget(tree.symbol, derived)
6071

6172
/** Converts the type `info` of a member of class `clazz` to a method type that
6273
* takes the `this` of the class and any type parameters of the class
@@ -151,8 +162,7 @@ trait FullParameterization {
151162
*/
152163
def rewireTree(tree: Tree, targs: List[Tree])(implicit ctx: Context): Tree = {
153164
def rewireCall(thisArg: Tree): Tree = {
154-
val sym = tree.symbol
155-
val rewired = rewiredTarget(sym, derived)
165+
val rewired = rewiredTarget(tree, derived)
156166
if (rewired.exists) {
157167
val base = thisArg.tpe.baseTypeWithArgs(origClass)
158168
assert(base.exists)

0 commit comments

Comments
 (0)