summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/TreeGen.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2016-07-22 09:50:04 +1000
committerJason Zaugg <jzaugg@gmail.com>2016-07-22 09:59:25 +1000
commit04649c74c47af1b6e21648e4dfe7db0417f3a9ba (patch)
tree555f182a49057890cfd7c89ff1e816b5f66b8fb6 /src/compiler/scala/tools/nsc/ast/TreeGen.scala
parent4e564efb04e508ccc0f479cf1a25331501927d88 (diff)
downloadscala-04649c74c47af1b6e21648e4dfe7db0417f3a9ba.tar.gz
scala-04649c74c47af1b6e21648e4dfe7db0417f3a9ba.tar.bz2
scala-04649c74c47af1b6e21648e4dfe7db0417f3a9ba.zip
SD-186 Fix positions in trait method bytecode
Concrete, non private methods in traits are translated into a static method with an explicit `$this` parameter. After this translation, the references to `$this` (subistuted for `this` in user written code) where being positioned at the position of the method, which makes debugging unpleasant. This commit leaves the `Ident($this)` trees unpositioned. This is analagous to what we do in the body of extension methods, which is the other user of `ThisSubstitutor`. It would be more correct to copy the position of each `This` tree over to the substituted tree. That would let us set a breakpoint on a line that _only_ contained `this`. But in 99% of cases users won't be able to spot the difference, so I've opted for the tried and tested approach here.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/TreeGen.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeGen.scala2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
index bc89609a59..2a4b1b6738 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
@@ -350,7 +350,7 @@ abstract class TreeGen extends scala.reflect.internal.TreeGen with TreeDSL {
case mt @ MethodType(params, res) => copyMethodType(mt, selfParamSym :: params, res)
})
val selfParam = ValDef(selfParamSym)
- val rhs = orig.rhs.substituteThis(newSym.owner, atPos(newSym.pos)(gen.mkAttributedIdent(selfParamSym)))
+ val rhs = orig.rhs.substituteThis(newSym.owner, gen.mkAttributedIdent(selfParamSym)) // SD-186 intentionally leaving Ident($this) is unpositioned
.substituteSymbols(origParams, newSym.info.params.drop(1)).changeOwner(origSym -> newSym)
treeCopy.DefDef(orig, orig.mods, orig.name, orig.tparams, (selfParam :: orig.vparamss.head) :: Nil, orig.tpt, rhs).setSymbol(newSym)
}