Skip to content

Commit 7e6968c

Browse files
authored
Merge pull request #1338 from dotty-jvican/non-deferred-ycheck
Check non-deferred declarations are implemented
2 parents a69d1b3 + f7a9957 commit 7e6968c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@ import Decorators._
3636

3737
override def phaseName = "memoize"
3838

39+
/* Makes sure that, after getters and constructors gen, there doesn't
40+
* exist non-deferred definitions that are not implemented. */
41+
override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = {
42+
def errorLackImplementation(t: Tree) = {
43+
val firstPhaseId = t.symbol.initial.validFor.firstPhaseId
44+
val definingPhase = ctx.withPhase(firstPhaseId).phase.prev
45+
throw new AssertionError(
46+
i"Non-deferred definition introduced by $definingPhase lacks implementation: $t")
47+
}
48+
tree match {
49+
case ddef: DefDef
50+
if !ddef.symbol.is(Deferred) && ddef.rhs == EmptyTree =>
51+
errorLackImplementation(ddef)
52+
case tdef: TypeDef
53+
if tdef.symbol.isClass && !tdef.symbol.is(Deferred) && tdef.rhs == EmptyTree =>
54+
errorLackImplementation(tdef)
55+
case _ =>
56+
}
57+
super.checkPostCondition(tree)
58+
}
59+
3960
/** Should run after mixin so that fields get generated in the
4061
* class that contains the concrete getter rather than the trait
4162
* that defines it.

0 commit comments

Comments
 (0)