diff options
author | Paul Phillips <paulp@improving.org> | 2011-12-27 15:54:32 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-12-28 08:43:13 -0800 |
commit | d05881e42e661986286ac15c2a8c32f651b0101e (patch) | |
tree | e09f124ca83106f542682d51bc10e430c35bdd72 /test/files/run | |
parent | 33ab1a574af0d5f736ab73c5a18cc6a4cb36cbb0 (diff) | |
download | scala-d05881e42e661986286ac15c2a8c32f651b0101e.tar.gz scala-d05881e42e661986286ac15c2a8c32f651b0101e.tar.bz2 scala-d05881e42e661986286ac15c2a8c32f651b0101e.zip |
repl power mode improvements.
Implemented great suggestion from moors. More imports in power mode,
including the contents of treedsl. Also, another swing at overcoming
the mismatched global singletons problem, this time taking advantage of
dependent method types. Amazingly, it seems to work.
Continuing in the quest to create a useful compiler hacking environment,
there is now an implicit from Symbol which allows you to pretend a
Symbol takes type parameters, and the result is the applied type based
on the manifests of the type arguments and the type constructor of the
symbol. Examples:
// magic with manifests
scala> val tp = ArrayClass[scala.util.Random]
tp: $r.global.Type = Array[scala.util.Random]
// evidence
scala> tp.memberType(Array_apply)
res0: $r.global.Type = (i: Int)scala.util.Random
// treedsl
scala> val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE)
m: $r.treedsl.global.Match =
10 match {
case 5 => false
case _ => true
}
// typed is in scope
scala> typed(m).tpe
res1: $r.treedsl.global.Type = Boolean
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/repl-power.check | 22 | ||||
-rw-r--r-- | test/files/run/repl-power.scala | 4 |
2 files changed, 23 insertions, 3 deletions
diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index 38e7532133..1e7b6f0cd8 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -2,15 +2,31 @@ Type in expressions to have them evaluated. Type :help for more information. scala> :power -** Power User mode enabled - BEEP BOOP SPIZ ** +** Power User mode enabled - BEEP WHIR GYVE ** ** :phase has been set to 'typer'. ** ** scala.tools.nsc._ has been imported ** -** global._ and definitions._ also imported ** -** Try :help, vals.<tab>, power.<tab> ** +** global._, definitions._ also imported ** +** Try :help, :vals, power.<tab> ** scala> // guarding against "error: reference to global is ambiguous" scala> global.emptyValDef // "it is imported twice in the same scope by ..." res0: $r.global.emptyValDef.type = private val _ = _ +scala> val tp = ArrayClass[scala.util.Random] // magic with manifests +tp: $r.global.Type = Array[scala.util.Random] + +scala> tp.memberType(Array_apply) // evidence +res1: $r.global.Type = (i: Int)scala.util.Random + +scala> val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl +m: $r.treedsl.global.Match = +10 match { + case 5 => false + case _ => true +} + +scala> typed(m).tpe // typed is in scope +res2: $r.treedsl.global.Type = Boolean + scala> diff --git a/test/files/run/repl-power.scala b/test/files/run/repl-power.scala index 9f70ac4b68..27da3df106 100644 --- a/test/files/run/repl-power.scala +++ b/test/files/run/repl-power.scala @@ -5,6 +5,10 @@ object Test extends ReplTest { :power // guarding against "error: reference to global is ambiguous" global.emptyValDef // "it is imported twice in the same scope by ..." +val tp = ArrayClass[scala.util.Random] // magic with manifests +tp.memberType(Array_apply) // evidence +val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl +typed(m).tpe // typed is in scope """.trim } |