11package dotty .tools .dotc
22package transform
33
4- import MegaPhase ._
5- import core .Denotations ._
6- import core .SymDenotations ._
7- import core .Contexts ._
8- import core .Types ._
9- import ast .Trees ._
10- import ast .tpd .{Apply , Tree , cpy }
11- import dotty .tools .dotc .ast .tpd
12- import scala .collection .mutable
13- import dotty .tools .dotc ._
14- import core ._
15- import Contexts ._
16- import Symbols ._
17- import Decorators ._
18- import NameOps ._
194import dotty .tools .dotc .ast .Trees ._
20- import dotty .tools .dotc .ast .{ untpd , tpd }
5+ import dotty .tools .dotc .ast .tpd
216import dotty .tools .dotc .core .Constants .Constant
22- import dotty .tools .dotc .core .Types .MethodType
23- import dotty .tools .dotc .core .Names .{ Name , TermName }
24- import scala .collection .mutable .ListBuffer
25- import dotty .tools .dotc .core .Denotations .SingleDenotation
26- import dotty .tools .dotc .core .SymDenotations .SymDenotation
27- import StdNames ._
28- import Phases .Phase
7+ import dotty .tools .dotc .core .Contexts ._
8+ import dotty .tools .dotc .core .Names .TermName
9+ import dotty .tools .dotc .core .StdNames ._
10+ import dotty .tools .dotc .core .Symbols ._
11+ import dotty .tools .dotc .core .Types ._
12+ import dotty .tools .dotc .transform .MegaPhase .MiniPhase
2913
3014object InterceptedMethods {
3115 val name = " intercepted"
@@ -45,9 +29,19 @@ class InterceptedMethods extends MiniPhase {
4529 override def phaseName : String = InterceptedMethods .name
4630
4731 // this should be removed if we have guarantee that ## will get Apply node
48- override def transformSelect (tree : tpd.Select )(implicit ctx : Context ): Tree = {
49- if (tree.symbol.isTerm && (defn.Any_## eq tree.symbol.asTerm)) {
50- val rewrite = poundPoundValue(tree.qualifier)
32+ override def transformSelect (tree : tpd.Select )(implicit ctx : Context ): Tree =
33+ transformRefTree(tree)
34+
35+ override def transformIdent (tree : tpd.Ident )(implicit ctx : Context ): Tree =
36+ transformRefTree(tree)
37+
38+ private def transformRefTree (tree : RefTree )(implicit ctx : Context ): Tree = {
39+ if (tree.symbol.isTerm && (defn.Any_## eq tree.symbol)) {
40+ val qual = tree match {
41+ case id : Ident => tpd.desugarIdentPrefix(id)
42+ case sel : Select => sel.qualifier
43+ }
44+ val rewrite = poundPoundValue(qual)
5145 ctx.log(s " $phaseName rewrote $tree to $rewrite" )
5246 rewrite
5347 }
0 commit comments