summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/Power.scala15
-rw-r--r--test/files/run/repl-power.check18
-rw-r--r--test/files/run/repl-power.scala10
3 files changed, 36 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/Power.scala b/src/compiler/scala/tools/nsc/interpreter/Power.scala
index 8fbbbe7683..34b324f0ca 100644
--- a/src/compiler/scala/tools/nsc/interpreter/Power.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/Power.scala
@@ -56,7 +56,12 @@ abstract class Power[G <: Global](
val intp: IMain
) extends SharesGlobal[G] {
import intp.{ beQuietDuring, interpret, parse }
- import global.{ opt, definitions, stringToTermName, NoSymbol, NoType, analyzer, CompilationUnit }
+ import global.{
+ opt, definitions, analyzer,
+ stringToTermName, typeRef,
+ CompilationUnit,
+ NoSymbol, NoPrefix, NoType
+ }
abstract class SymSlurper {
def isKeep(sym: Symbol): Boolean
@@ -296,9 +301,7 @@ abstract class Power[G <: Global](
// fallback
implicit def replPrinting[T](x: T)(implicit pretty: Prettifier[T] = Prettifier.default[T]) = new PrintingConvenience[T](x)
}
- trait Implicits2 extends Implicits1 with SharesGlobal[G] {
- import global._
-
+ trait Implicits2 extends Implicits1 {
class RichSymbol(sym: Symbol) {
// convenient type application
def apply(targs: Type*): Type = typeRef(NoPrefix, sym, targs.toList)
@@ -320,9 +323,7 @@ abstract class Power[G <: Global](
implicit def replInputStream(in: InputStream)(implicit codec: Codec): RichInputStream = new RichInputStream(in)
implicit def replInputStreamURL(url: URL)(implicit codec: Codec) = replInputStream(url.openStream())
}
- object Implicits extends Implicits2 {
- val global: G = Power.this.global
- }
+ object Implicits extends Implicits2 { }
trait ReplUtilities {
def ?[T: Manifest] = InternalInfo[T]
diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check
new file mode 100644
index 0000000000..249e0f71e8
--- /dev/null
+++ b/test/files/run/repl-power.check
@@ -0,0 +1,18 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala> :power
+** Power User mode enabled - BEEP BOOP WHIR **
+** scala.tools.nsc._ has been imported **
+** global._ and definitions._ also imported **
+** New vals! Try repl, intp, global, power **
+** New cmds! :help to discover them **
+** New defs! Type power.<tab> to reveal **
+
+scala>
+scala> // guarding against "error: reference to global is ambiguous"
+
+scala> global.emptyValDef // "it is imported twice in the same scope by ..."
+res0: global.emptyValDef.type = private val _ = _
+
+scala>
diff --git a/test/files/run/repl-power.scala b/test/files/run/repl-power.scala
new file mode 100644
index 0000000000..9f70ac4b68
--- /dev/null
+++ b/test/files/run/repl-power.scala
@@ -0,0 +1,10 @@
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ def code = """
+:power
+// guarding against "error: reference to global is ambiguous"
+global.emptyValDef // "it is imported twice in the same scope by ..."
+ """.trim
+}
+