summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan@lightbend.com>2016-04-27 17:32:10 -0700
committerAdriaan Moors <adriaan@lightbend.com>2016-04-27 17:32:10 -0700
commit11dac0ff47d6b7527c069c2b7afa0924767c8960 (patch)
treeb9cd0f64ce0e3ef7a84148e84e088a9bd5df8c9a /src
parent93f209dd65d5c05fc2cb61916a850940499c9261 (diff)
parentee3f4fe55740b27ecc0325b00452e62005d1759a (diff)
downloadscala-11dac0ff47d6b7527c069c2b7afa0924767c8960.tar.gz
scala-11dac0ff47d6b7527c069c2b7afa0924767c8960.tar.bz2
scala-11dac0ff47d6b7527c069c2b7afa0924767c8960.zip
Merge pull request #5094 from lrytz/classOfUnit
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.