Skip to content

Commit 622dfc2

Browse files
committed
Drop ShadowedName
1 parent 29d85ad commit 622dfc2

File tree

9 files changed

+14
-53
lines changed

9 files changed

+14
-53
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ object NameKinds {
350350

351351
val SuperAccessorName = new PrefixNameKind(SUPERACCESSOR, "super$")
352352
val InitializerName = new PrefixNameKind(INITIALIZER, "initial$")
353-
val ShadowedName = new PrefixNameKind(SHADOWED, "(shadowed)")
354353
val ProtectedAccessorName = new PrefixNameKind(PROTECTEDACCESSOR, "protected$")
355354
val ProtectedSetterName = new PrefixNameKind(PROTECTEDSETTER, "protected$set") // dubious encoding, kept for Scala2 compatibility
356355
val AvoidClashName = new SuffixNameKind(AVOIDCLASH, "$_avoid_name_clash_$")

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ object StdNames {
2121
final val TRAIT_SETTER_SEPARATOR = "$_setter_$"
2222
final val SUPER_PREFIX = "super$"
2323
final val INITIALIZER_PREFIX = "initial$"
24-
final val SHADOWED_PREFIX = "(shadowed)"
2524
final val AVOID_CLASH_SUFFIX = "$_avoid_name_clash_$"
2625
final val MODULE_SUFFIX = "$"
2726
final val NAME_JOIN = "$"

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

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Symbols._
77
import Flags._
88
import Names._
99
import StdNames._, NameOps._
10-
import NameKinds.{ShadowedName, SkolemName, SignedName}
10+
import NameKinds.{SkolemName, SignedName}
1111
import Scopes._
1212
import Constants._
1313
import Contexts._
@@ -1764,8 +1764,7 @@ object Types {
17641764
def reloadDenot()(implicit ctx: Context) = setDenot(loadDenot)
17651765

17661766
protected def asMemberOf(prefix: Type, allowPrivate: Boolean)(implicit ctx: Context): Denotation =
1767-
if (name.is(ShadowedName)) prefix.nonPrivateMember(name.exclude(ShadowedName))
1768-
else if (nameSpace != noNameSpace) nameSpace.findMember(name, prefix, EmptyFlags)
1767+
if (nameSpace != noNameSpace) nameSpace.findMember(name, prefix, EmptyFlags)
17691768
else if (allowPrivate) prefix.member(name)
17701769
else prefix.nonPrivateMember(name)
17711770

@@ -1918,31 +1917,10 @@ object Types {
19181917
if (nameSpace == this.nameSpace) this
19191918
else NamedType(prefix, designator.withNameSpace(nameSpace))
19201919

1921-
/** Create a NamedType of the same kind as this type, but with a "inherited name".
1922-
* This is necessary to in situations like the following:
1923-
*
1924-
* class B { def m: T1 }
1925-
* class C extends B { private def m: T2; ... C.m }
1926-
* object C extends C
1927-
* object X { ... C.m }
1928-
*
1929-
* The two references of C.m in class C and object X refer to different
1930-
* definitions: The one in C refers to C#m whereas the one in X refers to B#m.
1931-
* But the type C.m must have only one denotation, so it can't refer to two
1932-
* members depending on context.
1933-
*
1934-
* In situations like this, the reference in X would get the type
1935-
* `<C.m>.shadowed` to make clear that we mean the inherited member, not
1936-
* the private one.
1937-
*
1938-
* Note: An alternative, possibly more robust scheme would be to give
1939-
* private members special names. A private definition would have a special
1940-
* name (say m' in the example above), but would be entered in its enclosing
1941-
* under both private and public names, so it could still be found by looking up
1942-
* the public name.
1920+
/** Create a NamedType of the same kind as this type, but without a namespace
19431921
*/
1944-
def shadowed(implicit ctx: Context): NamedType =
1945-
(designator: Designator) match { // Dotty deviation: need the widening
1922+
def withoutNameSpace(implicit ctx: Context): NamedType =
1923+
(designator: Designator) match { // Dotty deviation: need the widening
19461924
case LocalName(underlying, _) => NamedType(prefix, underlying)
19471925
case _ => this
19481926
}
@@ -2018,8 +1996,8 @@ object Types {
20181996
fixDenot(TermRef(prefix, designator1), prefix)
20191997
}
20201998

2021-
override def shadowed(implicit ctx: Context): NamedType =
2022-
fixDenot(super.shadowed.asInstanceOf[TermRef], prefix)
1999+
override def withoutNameSpace(implicit ctx: Context): NamedType =
2000+
fixDenot(super.withoutNameSpace.asInstanceOf[TermRef], prefix)
20232001
}
20242002

20252003
abstract case class TypeRef(override val prefix: Type, designator: TypeDesignator) extends NamedType {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ object TastyFormat {
249249
final val PROTECTEDACCESSOR = 21
250250
final val PROTECTEDSETTER = 22
251251
final val INITIALIZER = 23
252-
final val SHADOWED = 24
253252
final val AVOIDCLASH = 30
254253
final val DIRECT = 31
255254
final val FIELD = 32
@@ -468,7 +467,6 @@ object TastyFormat {
468467
case PROTECTEDACCESSOR => "PROTECTEDACCESSOR"
469468
case PROTECTEDSETTER => "PROTECTEDSETTER"
470469
case INITIALIZER => "INITIALIZER"
471-
case SHADOWED => "SHADOWED"
472470
case AVOIDCLASH => "AVOIDCLASH"
473471
case DIRECT => "DIRECT"
474472
case FIELD => "FIELD"

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,10 @@ class TreePickler(pickler: TastyPickler) {
333333
}
334334
case Select(qual, name) =>
335335
writeByte(if (name.isTypeName) SELECTtpt else SELECT)
336-
val realName = tree.tpe match {
337-
case tp: NamedType if tp.name.is(ShadowedName) => tp.name
338-
case _ => name
339-
}
340336
val sig = tree.tpe.signature
341337
pickleName(
342-
if (name.isTypeName || sig == Signature.NotAMethod) realName
343-
else SignedName(realName.toTermName, sig))
338+
if (name.isTypeName || sig == Signature.NotAMethod) name
339+
else SignedName(name.toTermName, sig))
344340
pickleTree(qual)
345341
case Apply(fun, args) =>
346342
writeByte(APPLY)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,7 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi
865865
val localCtx =
866866
if (name == nme.CONSTRUCTOR) ctx.addMode(Mode.InSuperCall) else ctx
867867
val qual = readTerm()(localCtx)
868-
val unshadowed = name.exclude(ShadowedName)
869-
untpd.Select(qual, unshadowed).withType(tpf(qual.tpe.widenIfUnstable))
868+
untpd.Select(qual, name).withType(tpf(qual.tpe.widenIfUnstable))
870869
}
871870

872871
def readQualId(): (untpd.Ident, TypeRef) = {

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import core.Types._
1111
import core.Names._
1212
import core.StdNames._
1313
import core.NameOps._
14-
import core.NameKinds.ShadowedName
1514
import core.Decorators._
1615
import core.Constants._
1716
import core.Definitions._
@@ -385,14 +384,8 @@ object Erasure {
385384
val sym = if (owner eq origSym.owner) origSym else owner.info.decl(origSym.name).symbol
386385
assert(sym.exists, origSym.showLocated)
387386

388-
def select(qual: Tree, sym: Symbol): Tree = {
389-
val name = tree.typeOpt match {
390-
case tp: NamedType if tp.name.is(ShadowedName) => sym.name.derived(ShadowedName)
391-
case _ => sym.name
392-
}
393-
untpd.cpy.Select(tree)(qual, sym.name)
394-
.withType(NamedType(qual.tpe, sym))
395-
}
387+
def select(qual: Tree, sym: Symbol): Tree =
388+
untpd.cpy.Select(tree)(qual, sym.name).withType(NamedType(qual.tpe, sym))
396389

397390
def selectArrayMember(qual: Tree, erasedPre: Type): Tree =
398391
if (erasedPre isRef defn.ObjectClass)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class ParamForwarding(thisTransformer: DenotTransformer) {
7272
if (alias.owner != currentClass.superClass)
7373
// need to use shadowed in order not to accidentally address an
7474
// intervening private forwarder in the superclass
75-
superAcc = superAcc.withType(superAcc.tpe.asInstanceOf[TermRef].shadowed)
75+
superAcc = superAcc.withType(superAcc.tpe.asInstanceOf[TermRef].withoutNameSpace)
7676
typr.println(i"adding param forwarder $superAcc")
7777
DefDef(sym, superAcc.ensureConforms(sym.info.widen))
7878
}

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ trait TypeAssigner {
188188
// an inherited non-private member with the same name and signature.
189189
val d2 = pre.nonPrivateMember(name)
190190
if (reallyExists(d2) && firstTry)
191-
// test(NamedType(pre, name, d2), false)
192-
test(tpe.shadowed.withDenot(d2), false)
191+
test(tpe.withoutNameSpace.withDenot(d2), false)
193192
else if (pre.derivesFrom(defn.DynamicClass)) {
194193
TryDynamicCallType
195194
} else {

0 commit comments

Comments
 (0)