diff options
author | jvican <jorgevc@fastmail.es> | 2016-06-28 22:48:22 +0200 |
---|---|---|
committer | jvican <jorgevc@fastmail.es> | 2016-06-29 08:36:19 +0200 |
commit | f7a995791506935304a7f976be4791b32d41ca40 (patch) | |
tree | 0275fe506ebf6cf78bbb628e8eb9cc5b53ccde46 /src/dotty/tools/dotc/transform/Memoize.scala | |
parent | c7d1826cf0456e5efad5cb66ae06e7273c8a8e2a (diff) | |
download | dotty-f7a995791506935304a7f976be4791b32d41ca40.tar.gz dotty-f7a995791506935304a7f976be4791b32d41ca40.tar.bz2 dotty-f7a995791506935304a7f976be4791b32d41ca40.zip |
Add postcondition check that ensures #971
Diffstat (limited to 'src/dotty/tools/dotc/transform/Memoize.scala')
-rw-r--r-- | src/dotty/tools/dotc/transform/Memoize.scala | 21 |
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. |