Skip to content

Commit bd9e18f

Browse files
committed
Ycheck that companions do not disappear.
1 parent 61f1f4d commit bd9e18f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/dotty/tools/dotc/transform/TreeChecker.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ class TreeChecker extends Phase with SymTransformer {
5656
registry(name) = sym
5757
}
5858

59+
def checkCompanion(symd: SymDenotation)(implicit ctx: Context): Unit = {
60+
val cur = symd.linkedClass
61+
val prev = ctx.atPhase(ctx.phase.prev) {
62+
implicit ctx =>
63+
symd.symbol.linkedClass
64+
}
65+
66+
if (prev.exists)
67+
assert(cur.exists, i"companion disappeared from $symd")
68+
}
5969

6070
def transformSym(symd: SymDenotation)(implicit ctx: Context): SymDenotation = {
6171
val sym = symd.symbol
@@ -69,6 +79,8 @@ class TreeChecker extends Phase with SymTransformer {
6979
testDuplicate(sym, seenClasses, "class")
7080
}
7181

82+
checkCompanion(symd)
83+
7284
symd
7385
}
7486

0 commit comments

Comments
 (0)