Skip to content

Commit 0a09332

Browse files
committed
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.
1 parent 832a8eb commit 0a09332

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/dotty/tools/dotc/transform/Erasure.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import core.Decorators._
2121
import dotty.tools.dotc.ast.{Trees, tpd, untpd}
2222
import ast.Trees._
2323
import scala.collection.mutable.ListBuffer
24-
import dotty.tools.dotc.core.Flags
24+
import dotty.tools.dotc.core.{Constants, Flags}
2525
import ValueClasses._
2626
import TypeUtils._
2727
import ExplicitOuter._
@@ -299,8 +299,9 @@ object Erasure extends TypeTestsCasts{
299299
assignType(untpd.cpy.Typed(tree)(expr1, tpt1), tpt1)
300300
}
301301

302-
override def typedLiteral(tree: untpd.Literal)(implicit ctc: Context): Literal =
302+
override def typedLiteral(tree: untpd.Literal)(implicit ctx: Context): Literal =
303303
if (tree.typeOpt.isRef(defn.UnitClass)) tree.withType(tree.typeOpt)
304+
else if (tree.const.tag == Constants.ClazzTag) Literal(Constant(erasure(tree.const.typeValue)))
304305
else super.typedLiteral(tree)
305306

306307
/** Type check select nodes, applying the following rewritings exhaustively

0 commit comments

Comments
 (0)