summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Dubochet <gilles.dubochet@epfl.ch>2007-06-06 18:04:53 +0000
committerGilles Dubochet <gilles.dubochet@epfl.ch>2007-06-06 18:04:53 +0000
commit458adadcaf6e89f1cd876fe58cffc1343936d66d (patch)
tree022eac3882520111a90a95f2d5b3b00da68def41
parentcfb62d0b27dde4457b7072e6130c61dda5f5f243 (diff)
downloadscala-458adadcaf6e89f1cd876fe58cffc1343936d66d.tar.gz
scala-458adadcaf6e89f1cd876fe58cffc1343936d66d.tar.bz2
scala-458adadcaf6e89f1cd876fe58cffc1343936d66d.zip
The AST “Literal(Constant(t))” for t a value ty...
The AST “Literal(Constant(t))” for t a value type (int et al.) compiles consistently accross compilation targets.
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala17
-rw-r--r--test/files/run/structural.check2
-rw-r--r--test/files/run/structural.scala2
3 files changed, 12 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index c4658c361c..a734078614 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -292,22 +292,25 @@ abstract class CleanUp extends Transform {
/* end of dynamic call transformer. */
- case Template(parents, self, body) if (settings.target.value != "jvm-1.5" && !forMSIL) => //what is that?
- classConstantMeth.clear
- newDefs.clear
+ case Template(parents, self, body) =>
localTyper = typer.atOwner(tree, currentOwner)
- val body1 = transformTrees(body)
- copy.Template(tree, parents, self, newDefs.toList ::: body1)
- case Literal(c) if (c.tag == ClassTag) && (settings.target.value != "jvm-1.5" && !forMSIL) => //what is that?
+ if (settings.target.value != "jvm-1.5" && !forMSIL) {
+ classConstantMeth.clear
+ newDefs.clear
+ val body1 = transformTrees(body)
+ copy.Template(tree, parents, self, newDefs.toList ::: body1)
+ } else super.transform(tree)
+ case Literal(c) if (c.tag == ClassTag) =>
val tpe = c.typeValue
atPos(tree.pos) {
localTyper.typed {
if (isValueClass(tpe.symbol))
Select(gen.mkAttributedRef(javaBoxClassModule(tpe.symbol)), "TYPE")
- else
+ else if (settings.target.value != "jvm-1.5" && !forMSIL)
Apply(
gen.mkAttributedRef(classConstantMethod(tree.pos, signature(tpe))),
List())
+ else tree
}
}
case _ =>
diff --git a/test/files/run/structural.check b/test/files/run/structural.check
index 4d1b20c40c..51fc44fe36 100644
--- a/test/files/run/structural.check
+++ b/test/files/run/structural.check
@@ -15,7 +15,7 @@
16. one
17. tieone
18. 2
-19. 20432397
+19. true
20. 1
21. ()
22. one
diff --git a/test/files/run/structural.scala b/test/files/run/structural.scala
index d49a4ea3ef..536208140b 100644
--- a/test/files/run/structural.scala
+++ b/test/files/run/structural.scala
@@ -86,7 +86,7 @@ object Test extends Application {
Console.println("16. " + r.m(Array("one", "two")))
Console.println("17. " + r.n(Array(t1, t2)))
Console.println("18. " + (r.o(0) + 1))
- Console.println("19. " + r.p(0).hashCode())
+ Console.println("19. " + (r.p(0).hashCode() > 0))
Console.println("20. " + r.q(0))
Console.println("21. " + r.r(0))
Console.println("22. " + r.m(r.s))