Skip to content

Commit 87a7430

Browse files
committed
Disallow use of toDenot and toClassDenot conversions in Symbols
We can't allow them in symbols since they would not kick in when Symbol and ClassSymbol are made opaque type aliases, because inside Symbols we know that these types are aliases of Denotations so no conversion would be applied then and we would possibly end up with a denotation at the wrong validity period.
1 parent 2b353ba commit 87a7430

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ object SymDenotations {
16001600

16011601
// ----- Sanity checks and debugging */
16021602

1603-
def debugString: String = toString + "#" + symbol.id // !!! DEBUG
1603+
def debugString: String = toString + "#" + common.id // !!! DEBUG
16041604

16051605
def hasSkolems(tp: Type): Boolean = tp match {
16061606
case tp: SkolemType => true

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,12 @@ object Symbols {
555555
/** Makes all class denotation operations available on class symbols */
556556
implicit def toClassDenot(cls: ClassSymbol)(using Context): ClassDenotation = cls.classDenot
557557

558+
/** Blocks use of `toDenot` conversion in Symbols itself */
559+
private implicit def toDenotALT(sym: Symbol)(using Context): SymDenotation = sym.denot
560+
561+
/** Blocks use of `toClassDenot` conversion in Symbols itself */
562+
private implicit def toClassDenotALT(cls: ClassSymbol)(using Context): ClassDenotation = cls.classDenot
563+
558564
/** The Definitions object */
559565
def defn(using Context): Definitions = ctx.definitions
560566

0 commit comments

Comments
 (0)