summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-09-23 13:10:44 -0700
committerEugene Burmako <xeno.by@gmail.com>2012-09-23 13:10:44 -0700
commit6ba05fdf09e8ff81dda1b946d9f89b2bba9ad33b (patch)
tree036259b945edcd48d57441d5440aa09f2a22c629 /test/files
parentbfd847848e82b2fad7170043cf07b3691c722e65 (diff)
parent3c8a98f7d566c28cdd7a679c6bfc8f35e92b970b (diff)
downloadscala-6ba05fdf09e8ff81dda1b946d9f89b2bba9ad33b.tar.gz
scala-6ba05fdf09e8ff81dda1b946d9f89b2bba9ad33b.tar.bz2
scala-6ba05fdf09e8ff81dda1b946d9f89b2bba9ad33b.zip
Merge pull request #1378 from scalamacros/ticket/5918
SI-5918 fixes the ConstantType ugliness
Diffstat (limited to 'test/files')
-rw-r--r--test/files/run/constant-type.check30
-rw-r--r--test/files/run/constant-type.scala17
2 files changed, 47 insertions, 0 deletions
diff --git a/test/files/run/constant-type.check b/test/files/run/constant-type.check
new file mode 100644
index 0000000000..dfd8be5297
--- /dev/null
+++ b/test/files/run/constant-type.check
@@ -0,0 +1,30 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> :power
+** Power User mode enabled - BEEP WHIR GYVE **
+** :phase has been set to 'typer'. **
+** scala.tools.nsc._ has been imported **
+** global._, definitions._ also imported **
+** Try :help, :vals, power.<tab> **
+
+scala> val s = transformedType(StringClass.toType).asInstanceOf[Type]
+s: $r.intp.global.Type = String
+
+scala> { println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) }
+Class[String](classOf[java.lang.String])
+
+scala> { afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) }
+Class(classOf[java.lang.String])
+
+scala> { ConstantType(Constant(s)); println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); }
+Class[String](classOf[java.lang.String])
+
+scala> { ConstantType(Constant(s)); afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); }
+Class(classOf[java.lang.String])
+
+scala>
+
+scala>
diff --git a/test/files/run/constant-type.scala b/test/files/run/constant-type.scala
new file mode 100644
index 0000000000..84539e2895
--- /dev/null
+++ b/test/files/run/constant-type.scala
@@ -0,0 +1,17 @@
+import scala.tools.partest.ReplTest
+
+// see the commit message to understand what this stuff is about
+// just a quick note:
+// transformedType returns an erased version of the type
+// as explained in the commit message, Type.erasure won't do for this test
+// because it does some postprocessing to the result of transformedType
+object Test extends ReplTest {
+ def code = """
+:power
+val s = transformedType(StringClass.toType).asInstanceOf[Type]
+{ println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) }
+{ afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) }
+{ ConstantType(Constant(s)); println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); }
+{ ConstantType(Constant(s)); afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); }
+ """
+}