|
1 | 1 | package dotty.tools.dotc
|
2 | 2 | package transform
|
3 | 3 |
|
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._ |
19 | 4 | import dotty.tools.dotc.ast.Trees._
|
20 |
| -import dotty.tools.dotc.ast.{untpd, tpd} |
| 5 | +import dotty.tools.dotc.ast.tpd |
21 | 6 | import 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 |
29 | 13 |
|
30 | 14 | object InterceptedMethods {
|
31 | 15 | val name = "intercepted"
|
@@ -54,6 +38,16 @@ class InterceptedMethods extends MiniPhase {
|
54 | 38 | else tree
|
55 | 39 | }
|
56 | 40 |
|
| 41 | + override def transformIdent(tree: tpd.Ident)(implicit ctx: Context): Tree = { |
| 42 | + if (tree.symbol.isTerm && (defn.Any_## eq tree.symbol.asTerm)) { |
| 43 | + val cls = ctx.owner.ownersIterator.find(_.isClass).get.asClass |
| 44 | + val rewrite = poundPoundValue(This(cls)) |
| 45 | + ctx.log(s"$phaseName rewrote $tree to $rewrite") |
| 46 | + rewrite |
| 47 | + } |
| 48 | + else tree |
| 49 | + } |
| 50 | + |
57 | 51 | // TODO: add missing cases from scalac
|
58 | 52 | private def poundPoundValue(tree: Tree)(implicit ctx: Context) = {
|
59 | 53 | val s = tree.tpe.widen.typeSymbol
|
|
0 commit comments