diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2016-03-23 18:41:00 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2016-04-18 14:46:57 +0200 |
commit | 57fcea6ee648164d7fd7597b34d50709ddaf4952 (patch) | |
tree | 736daff69d6cfc25a32d2d712119092eb6ba9600 | |
parent | 3f41bd6a4c525eb7c40fd96aba7997c4dcfb8b86 (diff) | |
download | dotty-57fcea6ee648164d7fd7597b34d50709ddaf4952.tar.gz dotty-57fcea6ee648164d7fd7597b34d50709ddaf4952.tar.bz2 dotty-57fcea6ee648164d7fd7597b34d50709ddaf4952.zip |
Erasure: Erase constant literals.
The problem comes from JavaArrayTypes.
They are invalid before erasure, and cannot be pickled,
while Array[T] is invalid after erasure and should be erased.
-rw-r--r-- | src/dotty/tools/dotc/transform/Erasure.scala | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/transform/Erasure.scala b/src/dotty/tools/dotc/transform/Erasure.scala index 4e7bcffd4..0b3a07f65 100644 --- a/src/dotty/tools/dotc/transform/Erasure.scala +++ b/src/dotty/tools/dotc/transform/Erasure.scala @@ -21,7 +21,7 @@ import core.Decorators._ import dotty.tools.dotc.ast.{Trees, tpd, untpd} import ast.Trees._ import scala.collection.mutable.ListBuffer -import dotty.tools.dotc.core.Flags +import dotty.tools.dotc.core.{Constants, Flags} import ValueClasses._ import TypeUtils._ import ExplicitOuter._ @@ -299,8 +299,9 @@ object Erasure extends TypeTestsCasts{ assignType(untpd.cpy.Typed(tree)(expr1, tpt1), tpt1) } - override def typedLiteral(tree: untpd.Literal)(implicit ctc: Context): Literal = + override def typedLiteral(tree: untpd.Literal)(implicit ctx: Context): Literal = if (tree.typeOpt.isRef(defn.UnitClass)) tree.withType(tree.typeOpt) + else if (tree.const.tag == Constants.ClazzTag) Literal(Constant(erasure(tree.const.typeValue))) else super.typedLiteral(tree) /** Type check select nodes, applying the following rewritings exhaustively |