Skip to content

Commit 07d38c2

Browse files
committed
Drop OverloadedSymbol/Denotation
It caused errors even in the old scheme, because we now had another symbol that "existed" yet did not have an owner. Also, change creation methods for NamedTypes to accommodate NoSymbol as a symbol of an overloaded denotation.
1 parent 4acb823 commit 07d38c2

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,15 +1857,13 @@ object SymDenotations {
18571857
override def owner: Symbol = throw new AssertionError("NoDenotation.owner")
18581858
override def computeAsSeenFrom(pre: Type)(implicit ctx: Context): SingleDenotation = this
18591859
override def mapInfo(f: Type => Type)(implicit ctx: Context): SingleDenotation = this
1860+
sym.denot = this
18601861
validFor = Period.allInRun(NoRunId)
18611862
}
18621863

1863-
@sharable val NoDenotation =
1864+
@sharable val NoDenotation: NoDenotation =
18641865
new NoDenotation(NoSymbol, "<none>".toTermName, exists = false)
18651866

1866-
@sharable val OverloadedDenotation =
1867-
new NoDenotation(OverloadedSymbol, "<overloaded>".toTermName, exists = true)
1868-
18691867
// ---- Completion --------------------------------------------------------
18701868

18711869
/** Instances of LazyType are carried by uncompleted symbols.

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -650,19 +650,12 @@ object Symbols {
650650
denot = underlying.denot
651651
}
652652

653-
class NonExistingSymbol extends Symbol(NoCoord, 0) {
653+
@sharable val NoSymbol = new Symbol(NoCoord, 0) {
654654
override def associatedFile(implicit ctx: Context): AbstractFile = NoSource.file
655655
override def recomputeDenot(lastd: SymDenotation)(implicit ctx: Context): SymDenotation = NoDenotation
656656
}
657657

658-
@sharable object NoSymbol extends NonExistingSymbol {
659-
denot = NoDenotation
660-
}
661-
662-
@sharable object OverloadedSymbol extends NonExistingSymbol {
663-
denot = OverloadedDenotation
664-
type ThisName = TermName
665-
}
658+
NoDenotation // force it in order to set `denot` field of NoSymbol
666659

667660
implicit class Copier[N <: Name](sym: Symbol { type ThisName = N })(implicit ctx: Context) {
668661
/** Copy a symbol, overriding selective fields */

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,7 @@ object Types {
20972097
def applyOLD(prefix: Type, designator: TermDesignator)(implicit ctx: Context): TermRef =
20982098
ctx.uniqueNamedTypes.enterIfNew(prefix, designator, isTerm = true).asInstanceOf[TermRef]
20992099

2100-
def apply(prefix: Type, designator: TermSymbol)(implicit ctx: Context): TermRef =
2100+
def apply(prefix: Type, designator: Symbol)(implicit ctx: Context): TermRef =
21012101
ctx.uniqueNamedTypes.enterIfNew(prefix, designator, isTerm = true).asInstanceOf[TermRef]
21022102

21032103
/** Create term ref to given initial denotation, taking the signature
@@ -2115,7 +2115,7 @@ object Types {
21152115
} withDenot denot
21162116

21172117
def withDenot(prefix: Type, denot: Denotation)(implicit ctx: Context): TermRef =
2118-
apply(prefix, denot.symbol.asTerm).withDenot(denot)
2118+
apply(prefix, denot.symbol).withDenot(denot)
21192119

21202120
/** Create a term ref referring to given symbol with given name.
21212121
* This is similar to TermRef(Type, Symbol), except:
@@ -2137,7 +2137,7 @@ object Types {
21372137
ctx.uniqueNamedTypes.enterIfNew(prefix, desig, isTerm = false).asInstanceOf[TypeRef]
21382138

21392139
/** Create type ref with given prefix and name */
2140-
def apply(prefix: Type, desig: TypeSymbol)(implicit ctx: Context): TypeRef =
2140+
def apply(prefix: Type, desig: Symbol)(implicit ctx: Context): TypeRef =
21412141
ctx.uniqueNamedTypes.enterIfNew(prefix, desig, isTerm = false).asInstanceOf[TypeRef]
21422142

21432143
/** Create a type ref with given name and initial denotation */
@@ -2148,7 +2148,7 @@ object Types {
21482148
} withDenot denot
21492149

21502150
def withDenot(prefix: Type, denot: Denotation)(implicit ctx: Context): TypeRef =
2151-
apply(prefix, denot.symbol.asType).withDenot(denot)
2151+
apply(prefix, denot.symbol).withDenot(denot)
21522152

21532153
/** Create a type ref referring to either a given symbol or its name.
21542154
* This is similar to TypeRef(prefix, sym), except:

0 commit comments

Comments
 (0)