diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-09-24 18:06:18 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-09-24 18:06:18 +0200 |
commit | f50c3f0d1c80a9d9d98d24ed3e7d8577c5eb80a5 (patch) | |
tree | 77dcd52fd5a44ef6916a49c3aac1bf122f72b294 /src/dotty/tools/dotc/transform/Erasure.scala | |
parent | 42b8c1df6e22bf8a8fd982bbd542d6fc427f8deb (diff) | |
download | dotty-f50c3f0d1c80a9d9d98d24ed3e7d8577c5eb80a5.tar.gz dotty-f50c3f0d1c80a9d9d98d24ed3e7d8577c5eb80a5.tar.bz2 dotty-f50c3f0d1c80a9d9d98d24ed3e7d8577c5eb80a5.zip |
Incorporating TypeTestsCasts into Erasure
Diffstat (limited to 'src/dotty/tools/dotc/transform/Erasure.scala')
-rw-r--r-- | src/dotty/tools/dotc/transform/Erasure.scala | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/transform/Erasure.scala b/src/dotty/tools/dotc/transform/Erasure.scala index d95d1379e..aae1ff1ba 100644 --- a/src/dotty/tools/dotc/transform/Erasure.scala +++ b/src/dotty/tools/dotc/transform/Erasure.scala @@ -32,7 +32,7 @@ class Erasure extends Phase with DenotTransformer { thisTransformer => override def phaseName: String = "erasure" /** List of names of phases that should precede this phase */ - override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[TypeTestsCasts], classOf[InterceptedMethods], classOf[Splitter], classOf[ElimRepeated]) + override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[InterceptedMethods], classOf[Splitter], classOf[ElimRepeated]) def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation = ref match { case ref: SymDenotation => @@ -104,7 +104,7 @@ class Erasure extends Phase with DenotTransformer { thisTransformer => assert(isErasedType(tp), i"The type $tp - ${tp.toString} of class ${tp.getClass} of tree $tree / ${tree.getClass} is illegal after erasure, phase = ${ctx.phase}") } -object Erasure { +object Erasure extends TypeTestsCasts{ import tpd._ @@ -173,7 +173,7 @@ object Erasure { .appliedToNone cast(tree1, pt) case _ => - val cls = pt.classSymbol + val cls = pt.widen.classSymbol if (cls eq defn.UnitClass) constant(tree, Literal(Constant(()))) else { assert(cls ne defn.ArrayClass) @@ -329,13 +329,18 @@ object Erasure { } override def typedTypeApply(tree: untpd.TypeApply, pt: Type)(implicit ctx: Context) = { - val TypeApply(fun, args) = tree - val fun1 = typedExpr(fun, WildcardType) - fun1.tpe.widen match { - case funTpe: PolyType => - val args1 = args.mapconserve(typedType(_)) - untpd.cpy.TypeApply(tree)(fun1, args1).withType(funTpe.instantiate(args1.tpes)) - case _ => fun1 + val ntree = interceptTypeApply(tree.asInstanceOf[TypeApply]) + + ntree match { + case TypeApply(fun, args) => + val fun1 = typedExpr(fun, WildcardType) + fun1.tpe.widen match { + case funTpe: PolyType => + val args1 = args.mapconserve(typedType(_)) + untpd.cpy.TypeApply(tree)(fun1, args1).withType(funTpe.instantiate(args1.tpes)) + case _ => fun1 + } + case _ => typedExpr(ntree, pt) } } |