summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2016-04-11 21:12:01 +0200
committerLukas Rytz <lukas.rytz@gmail.com>2016-04-20 15:51:16 +0200
commitee3f4fe55740b27ecc0325b00452e62005d1759a (patch)
tree5e832c8a1bafd6101ab98757da410ca1d2ab095c /src
parentd24e298cbd955101a6b4342602b32ed37643dfb0 (diff)
downloadscala-ee3f4fe55740b27ecc0325b00452e62005d1759a.tar.gz
scala-ee3f4fe55740b27ecc0325b00452e62005d1759a.tar.bz2
scala-ee3f4fe55740b27ecc0325b00452e62005d1759a.zip
Fix erasure for classOf[Unit], don't erase to classOf[BoxedUnit]
Diffstat (limited to 'src')
-rw-r--r--src/reflect/scala/reflect/internal/transform/Erasure.scala5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/reflect/scala/reflect/internal/transform/Erasure.scala b/src/reflect/scala/reflect/internal/transform/Erasure.scala
index c069e2c198..412c49f571 100644
--- a/src/reflect/scala/reflect/internal/transform/Erasure.scala
+++ b/src/reflect/scala/reflect/internal/transform/Erasure.scala
@@ -113,7 +113,8 @@ trait Erasure {
def apply(tp: Type): Type = tp match {
case ConstantType(ct) =>
- if (ct.tag == ClazzTag) ConstantType(Constant(apply(ct.typeValue)))
+ // erase classOf[List[_]] to classOf[List]. special case for classOf[Unit], avoid erasing to classOf[BoxedUnit].
+ if (ct.tag == ClazzTag && ct.typeValue.typeSymbol != UnitClass) ConstantType(Constant(apply(ct.typeValue)))
else tp
case st: ThisType if st.sym.isPackageClass =>
tp
@@ -165,7 +166,7 @@ trait Erasure {
/** The erasure |T| of a type T. This is:
*
- * - For a constant type, itself.
+ * - For a constant type classOf[T], classOf[|T|], unless T is Unit. For any other constant type, itself.
* - For a type-bounds structure, the erasure of its upper bound.
* - For every other singleton type, the erasure of its supertype.
* - For a typeref scala.Array+[T] where T is an abstract type, AnyRef.