diff options
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/constant-type.check | 30 | ||||
-rw-r--r-- | test/files/run/constant-type.scala | 17 |
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)))); } + """ +} |