Skip to content

Commit 7e6e9ec

Browse files
committed
Use "$direct" instead of just "$" to prevent erasure clashes
Use "$direct" instead of just "$" to prevent erasure clashes of methods with erased context function results.
1 parent 64db3eb commit 7e6e9ec

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

compiler/src/dotty/tools/dotc/core/NameKinds.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ object NameKinds {
365365
val ExtMethName: SuffixNameKind = new SuffixNameKind(EXTMETH, "$extension")
366366
val ParamAccessorName: SuffixNameKind = new SuffixNameKind(PARAMACC, "$accessor")
367367
val ModuleClassName: SuffixNameKind = new SuffixNameKind(OBJECTCLASS, "$", optInfoString = "ModuleClass")
368-
val ImplMethName: SuffixNameKind = new SuffixNameKind(IMPLMETH, "$")
368+
val DirectMethName: SuffixNameKind = new SuffixNameKind(DIRECT, "$direct")
369369
val AdaptedClosureName: SuffixNameKind = new SuffixNameKind(ADAPTEDCLOSURE, "$adapted") { override def definesNewName = true }
370370
val SyntheticSetterName: SuffixNameKind = new SuffixNameKind(SETTER, "_$eq")
371371

compiler/src/dotty/tools/dotc/core/NameTags.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ object NameTags extends TastyFormat.NameTags {
2424

2525
final val ADAPTEDCLOSURE = 31 // Used in Erasure to adapt closures over primitive types.
2626

27-
final val IMPLMETH = 32 // Used to define methods in implementation classes
28-
// (can probably be removed).
27+
final val DIRECT = 32 // Used to define implementations of methods with
28+
// erased context function results that can override some
29+
// other method.
2930

3031
final val PARAMACC = 33 // Used for a private parameter alias
3132

@@ -48,7 +49,7 @@ object NameTags extends TastyFormat.NameTags {
4849
case INITIALIZER => "INITIALIZER"
4950
case FIELD => "FIELD"
5051
case EXTMETH => "EXTMETH"
51-
case IMPLMETH => "IMPLMETH"
52+
case DIRECT => "DIRECT"
5253
case PARAMACC => "PARAMACC"
5354
case ADAPTEDCLOSURE => "ADAPTEDCLOSURE"
5455
case OBJECTCLASS => "OBJECTCLASS"

compiler/src/dotty/tools/dotc/transform/Erasure.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import core.Types._
1212
import core.Names._
1313
import core.StdNames._
1414
import core.NameOps._
15-
import core.NameKinds.{AdaptedClosureName, BodyRetainerName, ImplMethName}
15+
import core.NameKinds.{AdaptedClosureName, BodyRetainerName, DirectMethName}
1616
import core.Scopes.newScopeWith
1717
import core.Decorators._
1818
import core.Constants._
@@ -63,10 +63,10 @@ class Erasure extends Phase with DenotTransformer {
6363
&& contextResultsAreErased(ref.symbol)
6464
&& (ref.owner.is(Flags.Trait) || ref.symbol.allOverriddenSymbols.hasNext)
6565
then
66-
// Add a `$` to prevent this method from having the same signature
66+
// Add a `$direct` to prevent this method from having the same signature
6767
// as a method it overrides. We need a bridge between the
6868
// two methods, so they are not allowed to already override after erasure.
69-
ImplMethName(ref.targetName.asTermName)
69+
DirectMethName(ref.targetName.asTermName)
7070
else
7171
ref.targetName
7272

0 commit comments

Comments
 (0)