Skip to content

Check non-deferred declarations are implemented #1338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/dotty/tools/dotc/transform/Memoize.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down