Skip to content

Commit

Permalink
ElimErasedValueType: add checkPostCondition
Browse files Browse the repository at this point in the history
Also add it to Ycheck in the tests so that checkPostCondition is
actually called.
  • Loading branch information
smarter committed Mar 19, 2015
1 parent a83d9ba commit 318c685
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/dotty/tools/dotc/transform/ElimErasedValueType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dotty.tools.dotc
package transform

import ast.{Trees, tpd}
import core._
import core._, core.Decorators._
import TreeTransforms._, Phases.Phase
import Types._, Contexts._, Constants._, Names._, NameOps._, Flags._, DenotTransformers._
import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._, Scopes._, Denotations._
Expand Down Expand Up @@ -44,6 +44,16 @@ class ElimErasedValueType extends MiniPhaseTransform with DenotTransformer {
}
}

override def checkPostCondition(tree: tpd.Tree)(implicit ctx: Context) = {
val tp = tree.tpe
val erased = elimErasedValueType(tp)
assert(tp eq erased,
i"The type $tp of tree $tree contains ErasedValueType, it should have been erased to $erased by ElimErasedValueType.")
val name = tree.symbol.name
assert(name != nme.UNDERLYING2EVT && name != nme.EVT2UNDERLYING,
i"The symbol '${tree.symbol}' of tree $tree should not exist after phase ElimErasedValueType.")
}

// FIXME: Is using a TypeMap here the best solution?
def elimErasedValueType(tpe: Type)(implicit ctx: Context) = new TypeMap() {
def apply(tp: Type) = tp match {
Expand Down
2 changes: 1 addition & 1 deletion test/dotc/tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class tests extends CompilerTest {

implicit val defaultOptions = noCheckOptions ++ List(
"-Yno-deep-subtypes",
"-Ycheck:tailrec,resolveSuper,mixin,restoreScopes",
"-Ycheck:tailrec,resolveSuper,elimerasedvaluetype,mixin,restoreScopes",
"-d", "./out/"
)

Expand Down

0 comments on commit 318c685

Please sign in to comment.