Skip to content

Commit 44ca1a7

Browse files
committed
Improve PhantomDeclErasure postcondition check.
1 parent 25acecb commit 44ca1a7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,20 @@ class PhantomDeclErasure extends MiniPhaseTransform with InfoTransformer {
3030
*/
3131
override def checkPostCondition(tree: tpd.Tree)(implicit ctx: Context): Unit = {
3232
def assertNotPhantom(tpe: Type): Unit =
33-
assert(!tpe.derivesFrom(defn.PhantomAnyClass), "All phantom type values should be erased in " + tree)
33+
assert(!tpe.derivesFrom(defn.PhantomAnyClass), "All phantom type declarations should be erased in " + tree)
3434

3535
tree match {
3636
case _: TypeTree =>
3737
case ValDef(_, tpt, _) => assertNotPhantom(tpt.typeOpt)
3838
case DefDef(_, _, _, tpt, _) => assertNotPhantom(tpt.typeOpt)
3939
case tree: Trees.TypeDef[_] =>
40-
// tree.symbol.asClass.classInfo.decls // TODO check decls
40+
tree.symbol match {
41+
case sym: ClassSymbol =>
42+
assertNotPhantom(sym.info)
43+
assert(!sym.classInfo.decls.exists(sym2 => isPhantomMethodType(sym2.info)),
44+
"All phantom type declarations should be erased in " + sym.classInfo)
45+
case _ =>
46+
}
4147
case _ =>
4248
}
4349

0 commit comments

Comments
 (0)