summaryrefslogtreecommitdiff
path: root/test/files/neg/t2866.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-11-19 09:59:47 +1000
committerJason Zaugg <jzaugg@gmail.com>2014-11-19 09:59:47 +1000
commit74046bb943f33dfa6009af0ddfa9e2f7949b1d58 (patch)
tree3b0f905f198936c981d7d1f04ab789eb0d1d40e0 /test/files/neg/t2866.scala
parentb2ba80ac84f7125fd9e5c40adf0a2874c3fa9e3c (diff)
parenta77f01f546312cf6601f03794f909a09d34c5445 (diff)
downloadscala-74046bb943f33dfa6009af0ddfa9e2f7949b1d58.tar.gz
scala-74046bb943f33dfa6009af0ddfa9e2f7949b1d58.tar.bz2
scala-74046bb943f33dfa6009af0ddfa9e2f7949b1d58.zip
Merge pull request #4118 from retronym/ticket/5639
SI-5639 Fix spurious discarding of implicit import
Diffstat (limited to 'test/files/neg/t2866.scala')
-rw-r--r--test/files/neg/t2866.scala59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/files/neg/t2866.scala b/test/files/neg/t2866.scala
new file mode 100644
index 0000000000..55ebff9710
--- /dev/null
+++ b/test/files/neg/t2866.scala
@@ -0,0 +1,59 @@
+// for 2.7.x compatibility
+
+object A {
+ implicit val one = 1
+}
+
+object Test {
+
+ locally {
+ import A._
+ locally {
+ // assert(implicitly[Int] == 1) // error: could not find implicit value for parameter e: Int.
+ // !!! Why one A.one?
+ // (I assume you mean: why _not_ A.one? A.one is shadowed by local one.
+ // but the local one cannot be used yet because it does not have an explicit type.
+ implicit val one = 2
+ assert(implicitly[Int] == 2)
+ assert(one == 2)
+ }
+ }
+
+ locally {
+ import A._
+ implicit val one: Int = 2
+ assert(implicitly[Int] == 2)
+ assert(one == 2)
+ }
+
+ locally {
+ import A.one // warning: imported `one' is permanently hidden by definition of value one.
+ // !!! Really?
+ //assert(implicitly[Int] == 1)
+ implicit val one = 2
+ assert(implicitly[Int] == 2) // !!! why not 2?
+ assert(one == 2)
+ }
+
+ locally {
+ import A.one
+ assert(implicitly[Int] == 1)
+ implicit val two = 2
+ assert(implicitly[Int] == 2) // !!! Not ambiguous in 2.8.0. Ambigous in 2.7.6
+ }
+
+ locally {
+ import A._
+ assert(implicitly[Int] == 1)
+ implicit val two = 2
+ import A.{one => _}
+ assert(implicitly[Int] == 2) // !!! Not ambiguous in 2.8.0. Ambiguous in 2.7.6
+ }
+
+ locally {
+ import A.{one => _, _}
+ implicit val two = 2
+ assert(implicitly[Int] == 2) // not ambiguous in 2.8.0 nor im ambiguous in 2.7.6
+ }
+
+}