aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/NameKinds.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-03-29 18:56:29 +0200
committerMartin Odersky <odersky@gmail.com>2017-04-11 09:33:11 +0200
commitb595a98a5b51f3b328f1d69e6afc56f19129666d (patch)
treedd17e5385eaa05619377ff37f31cc09ceccd0c36 /compiler/src/dotty/tools/dotc/core/NameKinds.scala
parenta5d94d23341b2f30f677f1420f1ce088a0f1ed5b (diff)
downloaddotty-b595a98a5b51f3b328f1d69e6afc56f19129666d.tar.gz
dotty-b595a98a5b51f3b328f1d69e6afc56f19129666d.tar.bz2
dotty-b595a98a5b51f3b328f1d69e6afc56f19129666d.zip
New unmangling for ExpandedName
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/NameKinds.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/core/NameKinds.scala20
1 files changed, 19 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/NameKinds.scala b/compiler/src/dotty/tools/dotc/core/NameKinds.scala
index 2c5e3ee3e..eea5aefe3 100644
--- a/compiler/src/dotty/tools/dotc/core/NameKinds.scala
+++ b/compiler/src/dotty/tools/dotc/core/NameKinds.scala
@@ -151,9 +151,27 @@ object NameKinds {
val QualifiedName = new QualifiedNameKind(QUALIFIED, ".")
val FlattenedName = new QualifiedNameKind(FLATTENED, "$")
- val ExpandedName = new QualifiedNameKind(EXPANDED, str.EXPAND_SEPARATOR)
val TraitSetterName = new QualifiedNameKind(TRAITSETTER, str.TRAIT_SETTER_SEPARATOR)
+ val ExpandedName = new QualifiedNameKind(EXPANDED, str.EXPAND_SEPARATOR) {
+ private val FalseSuper = "$$super".toTermName
+ private val FalseSuperLength = FalseSuper.length
+
+ override def unmangle(name: SimpleTermName): TermName = {
+ var i = name.lastIndexOfSlice(str.EXPAND_SEPARATOR)
+ if (i < 0) name
+ else {
+ // Hack to make super accessors from traits work. They would otherwise fail because of #765
+ // The problem is that in `x$$super$$plus` the expansion prefix needs to be `x`
+ // instead of `x$$super`.
+ if (i > FalseSuperLength && name.slice(i - FalseSuperLength, i) == FalseSuper)
+ i -= FalseSuper.length
+
+ apply(name.take(i).asTermName, name.drop(i + str.EXPAND_SEPARATOR.length).asSimpleName)
+ }
+ }
+ }
+
val UniqueName = new UniqueNameKind("$") {
override def mkString(underlying: TermName, info: ThisInfo) =
if (underlying.isEmpty) "$" + info.num + "$" else super.mkString(underlying, info)