Skip to content

Commit 35cb1a9

Browse files
committed
Make "direct names" semantic
1 parent d6d62f8 commit 35cb1a9

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ object NameKinds {
248248
val ProtectedAccessorName = new PrefixNameKind(PROTECTEDACCESSOR, "protected$")
249249
val ProtectedSetterName = new PrefixNameKind(PROTECTEDSETTER, "protected$set") // dubious encoding, kept for Scala2 compatibility
250250
val AvoidClashName = new SuffixNameKind(AVOIDCLASH, "$_avoid_name_clash_$")
251+
val DirectName = new SuffixNameKind(DIRECT, "$direct")
251252
val ModuleClassName = new SuffixNameKind(OBJECTCLASS, "$", optInfoString = "ModuleClass")
252253

253254
object SignedName extends NameKind(63) {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ object NameOps {
143143

144144
def errorName: N = likeTyped(name ++ nme.ERROR)
145145

146-
def directName: N = likeTyped(name ++ DIRECT_SUFFIX)
147-
148146
def freshened(implicit ctx: Context): N = likeTyped {
149147
name.toTermName match {
150148
case ModuleClassName(original) => ModuleClassName(original.freshened)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ object StdNames {
132132
val COMPANION_MODULE_METHOD: N = "companion$module"
133133
val COMPANION_CLASS_METHOD: N = "companion$class"
134134
val TRAIT_SETTER_SEPARATOR: N = str.TRAIT_SETTER_SEPARATOR
135-
val DIRECT_SUFFIX: N = "$direct"
136135

137136
// value types (and AnyRef) are all used as terms as well
138137
// as (at least) arguments to the @specialize annotation.
@@ -166,7 +165,6 @@ object StdNames {
166165

167166
// fictions we use as both types and terms
168167
final val ERROR: N = "<error>"
169-
final val ERRORenc: N = encode("<error>")
170168
final val NO_NAME: N = "<none>" // formerly NOSYMBOL
171169
final val WILDCARD: N = "_"
172170

compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,11 @@ object TastyFormat {
234234
final val INITIALIZER = 23
235235
final val SHADOWED = 24
236236
final val AVOIDCLASH = 27
237+
final val DIRECT = 28
237238
final val OBJECTCLASS = 29
238239

239240
final val SIGNED = 63
241+
final val firstInternalTag = 64
240242

241243
// AST tags
242244

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import core.Decorators._
1111
import core.StdNames.nme
1212
import core.Names._
1313
import core.NameOps._
14+
import core.NameKinds.DirectName
1415
import ast.Trees._
1516
import ast.tpd
1617
import collection.mutable
@@ -91,7 +92,7 @@ class ShortcutImplicits extends MiniPhase with IdentityDenotTransformer { thisTr
9192
/** A new `m$direct` method to accompany the given method `m` */
9293
private def newDirectMethod(sym: Symbol)(implicit ctx: Context): Symbol = {
9394
val direct = sym.copy(
94-
name = sym.name.directName,
95+
name = DirectName(sym.name.asTermName).asInstanceOf[sym.ThisName],
9596
flags = sym.flags | Synthetic,
9697
info = directInfo(sym.info))
9798
if (direct.allOverriddenSymbols.isEmpty) direct.resetFlag(Override)
@@ -103,7 +104,7 @@ class ShortcutImplicits extends MiniPhase with IdentityDenotTransformer { thisTr
103104
*/
104105
private def directMethod(sym: Symbol)(implicit ctx: Context): Symbol =
105106
if (sym.owner.isClass) {
106-
val direct = sym.owner.info.member(sym.name.directName)
107+
val direct = sym.owner.info.member(DirectName(sym.name.asTermName))
107108
.suchThat(_.info matches directInfo(sym.info)).symbol
108109
if (direct.maybeOwner == sym.owner) direct
109110
else newDirectMethod(sym).enteredAfter(thisTransform)
@@ -121,7 +122,7 @@ class ShortcutImplicits extends MiniPhase with IdentityDenotTransformer { thisTr
121122
case TypeApply(fn, args) => cpy.TypeApply(tree)(directQual(fn), args)
122123
case Block(stats, expr) => cpy.Block(tree)(stats, directQual(expr))
123124
case tree: RefTree =>
124-
cpy.Ref(tree)(tree.name.directName)
125+
cpy.Ref(tree)(DirectName(tree.name.asTermName))
125126
.withType(directMethod(tree.symbol).termRef)
126127
}
127128
directQual(tree.qualifier)

0 commit comments

Comments
 (0)