diff options
author | Som Snytt <som.snytt@gmail.com> | 2015-06-15 11:21:06 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2015-07-06 22:04:54 -0700 |
commit | aa0f345de2955819e7048984a7e5fa0acb7e8bc2 (patch) | |
tree | 6d471a4c19baa068ba422a653b8131d56026dbac /test/files/run/t1931.scala | |
parent | 52fde52920d93325310e5544991feeea03e5c763 (diff) | |
download | scala-aa0f345de2955819e7048984a7e5fa0acb7e8bc2.tar.gz scala-aa0f345de2955819e7048984a7e5fa0acb7e8bc2.tar.bz2 scala-aa0f345de2955819e7048984a7e5fa0acb7e8bc2.zip |
SI-1931 Hide Predef.any2stringadd in REPL
User imports that reference Predef are relocated to the top of
the wrapping template so that they can hide implicits defined
in Predef.
Only one import from Predef is retained for special treatment.
This is simple and sane. The test shows that `import Predef._`
restores Predef implicits even if a user-defined term would
normally be in scope.
A smart `:import` command to turn off or quarantine imports explicitly
would allow fine-grained control.
Diffstat (limited to 'test/files/run/t1931.scala')
-rw-r--r-- | test/files/run/t1931.scala | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/files/run/t1931.scala b/test/files/run/t1931.scala new file mode 100644 index 0000000000..eedfa9b03d --- /dev/null +++ b/test/files/run/t1931.scala @@ -0,0 +1,43 @@ + +import scala.tools.partest.SessionTest + +object Test extends SessionTest { + + def session = +""" +scala> val x: Any = 42 +x: Any = 42 + +scala> x + " works" +res0: String = 42 works + +scala> import Predef.{ any2stringadd => _, _ } +import Predef.{any2stringadd=>_, _} + +scala> x + " works" +<console>:14: error: value + is not a member of Any + x + " works" + ^ + +scala> import Predef._ +import Predef._ + +scala> x + " works" +res2: String = 42 works + +scala> object Predef { def f = 42 } +defined object Predef + +scala> import Predef._ +import Predef._ + +scala> f +<console>:14: error: not found: value f + f + ^ + +scala> Predef.f +res4: Int = 42 + +scala> :quit""" +} |