Skip to content

Commit 58d68ae

Browse files
committed
Revert to old definition if isSelfSym
1 parent fb753dc commit 58d68ae

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,21 @@ object SymDenotations {
702702
flagsUNSAFE.is(Provisional) // do not force the info to check the flag
703703

704704
/** Is this the denotation of a self symbol of some class?
705-
*/
706-
final def isSelfSym(using Context): Boolean = is(SelfName)
705+
* This is the case if one of two conditions holds:
706+
* 1. It is the symbol referred to in the selfInfo part of the ClassInfo
707+
* which is the type of this symbol's owner.
708+
* 2. This symbol is owned by a class, it's selfInfo field refers to a type
709+
* (indicating the self definition does not introduce a name), and the
710+
* symbol's name is "_".
711+
* TODO: Find a more robust way to characterize self symbols, maybe by
712+
* spending a Flag on them?
713+
*/
714+
final def isSelfSym(using Context): Boolean = owner.infoOrCompleter match {
715+
case ClassInfo(_, _, _, _, selfInfo) =>
716+
selfInfo == symbol ||
717+
selfInfo.isInstanceOf[Type] && name == nme.WILDCARD
718+
case _ => false
719+
}
707720

708721
/** Is this definition contained in `boundary`?
709722
* Same as `ownersIterator contains boundary` but more efficient.

0 commit comments

Comments
 (0)