Skip to content

Commit 6545934

Browse files
committed
Fix #765 for super accessors
Partial fix of #765. Hack to make sure unexpandedName works for super accessor names.
1 parent 98d7183 commit 6545934

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/dotty/tools/dotc/core/NameOps.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,13 @@ object NameOps {
184184
* an encoded name, e.g. super$$plus$eq. See #765.
185185
*/
186186
def unexpandedName: N = {
187-
val idx = name.lastIndexOfSlice(nme.EXPAND_SEPARATOR)
187+
var idx = name.lastIndexOfSlice(nme.EXPAND_SEPARATOR)
188+
189+
// Hack to make super accessors from traits work. They would otherwise fail because of #765
190+
// TODO: drop this once we have more robust name handling
191+
if (name.slice(idx - FalseSuperLength, idx) == FalseSuper)
192+
idx -= FalseSuper.length
193+
188194
if (idx < 0) name else (name drop (idx + nme.EXPAND_SEPARATOR.length)).asInstanceOf[N]
189195
}
190196

@@ -436,4 +442,7 @@ object NameOps {
436442
name.dropRight(nme.LAZY_LOCAL.length)
437443
}
438444
}
445+
446+
private final val FalseSuper = "$$super".toTermName
447+
private val FalseSuperLength = FalseSuper.length
439448
}

0 commit comments

Comments
 (0)