Skip to content

Commit b0990fe

Browse files
committed
Don't use NotAMethod in SignedNames
Instead, assume that an unsigned name means NotAMethod.
1 parent c282303 commit b0990fe

File tree

9 files changed

+19
-17
lines changed

9 files changed

+19
-17
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ object Designators {
3535
def localizeIfPrivate(sym: Symbol)(implicit ctx: Context): Designator { type ThisName = self.ThisName } =
3636
if (sym.isPrivate) withNameSpace(sym.owner.typeRef) else this
3737

38-
def withSig(sig: Signature): Designator{ type ThisName = TermName } =
39-
SignedName(this.asInstanceOf[TermName].exclude(SignedName), sig)
38+
def withSig(sig: Signature): Designator{ type ThisName = TermName } = {
39+
val unsigned = this.asInstanceOf[TermName].exclude(SignedName)
40+
if (sig eq Signature.NotAMethod) unsigned else SignedName(unsigned, sig)
41+
}
4042
}
4143

4244
type TermDesignator = Designator { type ThisName = TermName }

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ object NameKinds {
366366
object SignedName extends NameKind(SIGNED) {
367367

368368
case class SignedInfo(sig: Signature) extends Info {
369+
assert(sig ne Signature.NotAMethod)
369370
override def toString = s"$infoString $sig"
370371
}
371372
type ThisInfo = SignedInfo

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,7 @@ object Types {
15091509
decompose(underlying)
15101510
case designator: Name =>
15111511
myName = designator.asInstanceOf[ThisName]
1512+
if (mySig == null) mySig = Signature.NotAMethod
15121513
case designator: Symbol =>
15131514
uncheckedSetSym(designator)
15141515
case LocalName(underlying, space) =>
@@ -1524,10 +1525,10 @@ object Types {
15241525
myName
15251526
}
15261527

1527-
final override def signature(implicit ctx: Context): Signature =
1528-
if (mySig != null) mySig
1529-
else if (isType || lastDenotation == null) Signature.NotAMethod
1530-
else denot.signature
1528+
final override def signature(implicit ctx: Context): Signature = {
1529+
if (mySig == null) mySig = denot.signature
1530+
mySig
1531+
}
15311532

15321533
final def nameSpace: NameSpace = myNameSpace
15331534

@@ -1974,7 +1975,7 @@ object Types {
19741975
// from the new prefix, modulo consistency
19751976
val curSig = signature
19761977
val newSig =
1977-
if (curSig == Signature.NotAMethod || !symbol.exists)
1978+
if (curSig.eq(Signature.NotAMethod) || !symbol.exists)
19781979
curSig
19791980
else
19801981
curSig.updateWith(symbol.info.asSeenFrom(prefix, symbol.owner).signature)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class TastyUnpickler(reader: TastyReader) {
6464
val result = readName().toTypeName
6565
val params = until(end)(readName().toTypeName)
6666
var sig = Signature(params, result)
67-
if (sig == Signature.NotAMethod) sig = Signature.NotAMethod
68-
SignedName(original, sig)
67+
if (sig == Signature.NotAMethod) sig = Signature.NotAMethod // needed temporarily, as long as we read old tasty
68+
original.withSig(sig).asInstanceOf[TermName]
6969
case _ =>
7070
simpleNameKindOfTag(tag)(readName())
7171
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ class TreePickler(pickler: TastyPickler) {
335335
writeByte(if (name.isTypeName) SELECTtpt else SELECT)
336336
val sig = tree.tpe.signature
337337
pickleName(
338-
if (name.isTypeName || sig == Signature.NotAMethod) name
338+
if (sig eq Signature.NotAMethod) name
339339
else SignedName(name.toTermName, sig))
340340
pickleTree(qual)
341341
case Apply(fun, args) =>

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,7 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi
720720
val cls = ctx.owner.asClass
721721
val assumedSelfType =
722722
if (cls.is(Module) && cls.owner.isClass)
723-
TermRef(
724-
cls.owner.thisType,
725-
cls.name.sourceModuleName.withSig(Signature.NotAMethod).localizeIfPrivate(cls))
723+
TermRef(cls.owner.thisType, cls.name.sourceModuleName.localizeIfPrivate(cls))
726724
else NoType
727725
cls.info = new TempClassInfo(cls.owner.thisType, cls, cls.unforcedDecls, assumedSelfType)
728726
val localDummy = symbolAtCurrent()

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
705705
val pre = readTypeRef()
706706
val sym = readDisambiguatedSymbolRef(_.info.isParameterless)
707707
if (isLocal(sym) || (pre eq NoPrefix)) pre select sym
708-
else TermRef(pre, sym.name.asTermName.withSig(Signature.NotAMethod)) // !!! should become redundant
708+
else TermRef(pre, sym.name.asTermName)
709709
case SUPERtpe =>
710710
val thistpe = readTypeRef()
711711
val supertpe = readTypeRef()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ class ParamForwarding(thisTransformer: DenotTransformer) {
9393

9494
def adaptRef[T <: RefTree](tree: T)(implicit ctx: Context): T = tree.tpe match {
9595
case tpe: TermRef
96-
if tpe.prefix.ne(NoPrefix) && tpe.signature == Signature.NotAMethod && tpe.symbol.is(Method) =>
96+
if tpe.prefix.ne(NoPrefix) && tpe.signature.eq(Signature.NotAMethod) && tpe.symbol.is(Method) =>
9797
// It could be a param forwarder; adapt the signature
9898
val newSig = tpe.prefix.memberInfo(tpe.symbol).signature
99-
if (newSig == Signature.NotAMethod) tree
99+
if (newSig.eq(Signature.NotAMethod)) tree
100100
else tree.withType(
101101
TermRef(tpe.prefix, tpe.name.withSig(newSig).localizeIfPrivate(tpe.symbol)))
102102
.asInstanceOf[T]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ trait ImplicitRunInfo { self: RunInfo =>
428428
def addRef(companion: TermRef): Unit = {
429429
val compSym = companion.symbol
430430
if (compSym is Package)
431-
addRef(TermRef(companion, nme.PACKAGE.withSig(Signature.NotAMethod)))
431+
addRef(TermRef(companion, nme.PACKAGE))
432432
else if (compSym.exists)
433433
comps += companion.asSeenFrom(pre, compSym.owner).asInstanceOf[TermRef]
434434
}

0 commit comments

Comments
 (0)