From 736dceb837d059df35c12f2d35fbbe0bf0f9f8f5 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 17 Jul 2014 10:57:58 +0200 Subject: Made FullParameterization more customizable Can now decide on rewiring on a node-by-nide basis. --- .../tools/dotc/transform/FullParameterization.scala | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/dotty/tools/dotc/transform/FullParameterization.scala b/src/dotty/tools/dotc/transform/FullParameterization.scala index a496716a5..fea0482a0 100644 --- a/src/dotty/tools/dotc/transform/FullParameterization.scala +++ b/src/dotty/tools/dotc/transform/FullParameterization.scala @@ -52,11 +52,22 @@ trait FullParameterization { import tpd._ - /** If references to original `target` from fully parameterized method `derived` should be - * rewired to some fully parameterized method, that method symbol, + /** If references to original symbol `referenced` from within fully parameterized method + * `derived` should be rewired to some fully parameterized method, the rewiring target symbol, * otherwise NoSymbol. */ - protected def rewiredTarget(target: Symbol, derived: Symbol)(implicit ctx: Context): Symbol + protected def rewiredTarget(referenced: Symbol, derived: Symbol)(implicit ctx: Context): Symbol + + /** If references to some original symbol from given tree node within fully parameterized method + * `derived` should be rewired to some fully parameterized method, the rewiring target symbol, + * otherwise NoSymbol. By default implemented as + * + * rewiredTarget(tree.symbol, derived) + * + * but can be overridden. + */ + protected def rewiredTarget(tree: Tree, derived: Symbol)(implicit ctx: Context): Symbol = + rewiredTarget(tree.symbol, derived) /** Converts the type `info` of a member of class `clazz` to a method type that * takes the `this` of the class and any type parameters of the class @@ -151,8 +162,7 @@ trait FullParameterization { */ def rewireTree(tree: Tree, targs: List[Tree])(implicit ctx: Context): Tree = { def rewireCall(thisArg: Tree): Tree = { - val sym = tree.symbol - val rewired = rewiredTarget(sym, derived) + val rewired = rewiredTarget(tree, derived) if (rewired.exists) { val base = thisArg.tpe.baseTypeWithArgs(origClass) assert(base.exists) -- cgit v1.2.3