aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/transform/Memoize.scala21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/transform/Memoize.scala b/src/dotty/tools/dotc/transform/Memoize.scala
index 1e4f8831b..01c240e3a 100644
--- a/src/dotty/tools/dotc/transform/Memoize.scala
+++ b/src/dotty/tools/dotc/transform/Memoize.scala
@@ -36,6 +36,27 @@ import Decorators._
override def phaseName = "memoize"
+ /* Makes sure that, after getters and constructors gen, there doesn't
+ * exist non-deferred definitions that are not implemented. */
+ override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = {
+ def errorLackImplementation(t: Tree) = {
+ val firstPhaseId = t.symbol.initial.validFor.firstPhaseId
+ val definingPhase = ctx.withPhase(firstPhaseId).phase.prev
+ throw new AssertionError(
+ i"Non-deferred definition introduced by $definingPhase lacks implementation: $t")
+ }
+ tree match {
+ case ddef: DefDef
+ if !ddef.symbol.is(Deferred) && ddef.rhs == EmptyTree =>
+ errorLackImplementation(ddef)
+ case tdef: TypeDef
+ if tdef.symbol.isClass && !tdef.symbol.is(Deferred) && tdef.rhs == EmptyTree =>
+ errorLackImplementation(tdef)
+ case _ =>
+ }
+ super.checkPostCondition(tree)
+ }
+
/** Should run after mixin so that fields get generated in the
* class that contains the concrete getter rather than the trait
* that defines it.