diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index fc3adf7d1..a5c619173 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -528,7 +528,8 @@ abstract class CleanUp extends Transform { val tpe = c.typeValue atPos(tree.pos) { localTyper.typed { - if (isValueClass(tpe.typeSymbol) && !forCLDC) + if ((isValueClass(tpe.typeSymbol) || tpe.typeSymbol == definitions.UnitClass) + && !forCLDC) Select(gen.mkAttributedRef(javaBoxClassModule(tpe.typeSymbol)), "TYPE") else if (settings.target.value != "jvm-1.5" && !forMSIL) Apply( diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 8ea138e28..3f76063a1 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -875,6 +875,10 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { case Match(selector, cases) => Match(Typed(selector, TypeTree(selector.tpe)), cases) + case Literal(ct) if ct.tag == ClassTag + && ct.typeValue.typeSymbol != definitions.UnitClass => + copy.Literal(tree, Constant(erasure(ct.typeValue))) + case _ => tree } diff --git a/test/files/jvm/manifests.check b/test/files/jvm/manifests.check index a2419d2b0..995fb5f1e 100644 --- a/test/files/jvm/manifests.check +++ b/test/files/jvm/manifests.check @@ -1,9 +1,9 @@ -x=(), m=java.lang.Void +x=(), m=void x=true, m=boolean x=a, m=char x=1, m=int x=abc, m=java.lang.String -x=List(()), m=scala.List[java.lang.Void] +x=List(()), m=scala.List[void] x=List(true), m=scala.List[boolean] x=List(1), m=scala.List[int] x=List(abc), m=scala.List[java.lang.String] @@ -11,7 +11,7 @@ x=[Z, m=[Z[boolean] x=[C, m=[C[char] x=[I, m=[I[int] x=Array(abc), m=[Ljava.lang.String;[java.lang.String] -x=((),()), m=scala.Tuple2[java.lang.Void, java.lang.Void] +x=((),()), m=scala.Tuple2[void, void] x=(true,false), m=scala.Tuple2[boolean, boolean] x=(1,2), m=scala.Tuple2[int, int] x=(abc,xyz), m=scala.Tuple2[java.lang.String, java.lang.String] diff --git a/test/files/run/classof.check b/test/files/run/classof.check index e9a8fd6b7..af7082f5b 100644 --- a/test/files/run/classof.check +++ b/test/files/run/classof.check @@ -1 +1,22 @@ -SomeClass +Value types: +void +boolean +byte +short +char +int +long +float +double +Class types +class SomeClass +class scala.List +class scala.Tuple2 +Arrays: +class [Lscala.runtime.BoxedUnit; +class [I +class [D +class [Lscala.List; +Functions: +interface scala.Function2 +interface scala.Function1 diff --git a/test/files/run/classof.scala b/test/files/run/classof.scala index 5c920d797..10c07d2e5 100755 --- a/test/files/run/classof.scala +++ b/test/files/run/classof.scala @@ -3,6 +3,30 @@ class SomeClass object Test { def main(args: Array[String]): Unit = { val cls: Predef.Class[SomeClass] = classOf[SomeClass] - Console.println(cls.getName()) + println("Value types:") + println(classOf[Unit]) + println(classOf[Boolean]) + println(classOf[Byte]) + println(classOf[Short]) + println(classOf[Char]) + println(classOf[Int]) + println(classOf[Long]) + println(classOf[Float]) + println(classOf[Double]) + + println("Class types") + println(classOf[SomeClass]) + println(classOf[List[Array[Float]]]) + println(classOf[(String, Map[Int, String])]) + + println("Arrays:") + println(classOf[Array[Unit]]) + println(classOf[Array[Int]]) + println(classOf[Array[Double]]) + println(classOf[Array[List[String]]]) + + println("Functions: ") + println(classOf[(Int, Int) => Unit]) + println(classOf[Int => Boolean]) } }