summaryrefslogtreecommitdiff
path: root/test/files/run/t5604.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-09-26 12:14:13 -0700
committerPaul Phillips <paulp@improving.org>2012-09-26 12:24:45 -0700
commite6f10b07d44f0ddde26246b4a41527a84eede81c (patch)
tree2268de6b9dccf22e3355b0ee1bcf63d7e7f10738 /test/files/run/t5604.scala
parent83b5d4c0c9af462fc562c571f17dfcd00f47255d (diff)
downloadscala-e6f10b07d44f0ddde26246b4a41527a84eede81c.tar.gz
scala-e6f10b07d44f0ddde26246b4a41527a84eede81c.tar.bz2
scala-e6f10b07d44f0ddde26246b4a41527a84eede81c.zip
Fixed SI-5604, selections on package objects.
mkAttributedSelect, which creates a Select tree based on a symbol, has been a major source of package object bugs, because it has not been accurately identifying selections on package objects. When selecting foo.bar, if foo turns out to be a package object, the created Select tree must be foo.`package`.bar However mkAttributedSelect was only examining the owner of the symbol, which means it would work if the package object defined bar directly, but not if it inherited it.
Diffstat (limited to 'test/files/run/t5604.scala')
-rw-r--r--test/files/run/t5604.scala50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/files/run/t5604.scala b/test/files/run/t5604.scala
new file mode 100644
index 0000000000..a06c8aab3e
--- /dev/null
+++ b/test/files/run/t5604.scala
@@ -0,0 +1,50 @@
+// a.scala
+// Fri Jan 13 11:31:47 PST 2012
+
+package foo {
+ object regular extends Duh {
+ def buh(n: Long) = println("long")
+ def buh(n: Double) = println("double")
+ }
+ class regular {
+ import regular._
+
+ duh(33L)
+ duh(3.0d)
+ foo.regular.duh(33L)
+ foo.regular.duh(3.0d)
+ buh(66L)
+ buh(6.0d)
+ foo.regular.buh(66L)
+ foo.regular.buh(6.0d)
+ }
+
+ trait Duh {
+ def duh(n: Long) = println("long")
+ def duh(n: Double) = println("double")
+ }
+ package object bar extends Duh {
+ def buh(n: Long) = println("long")
+ def buh(n: Double) = println("double")
+ }
+ package bar {
+ object Main {
+ def main(args:Array[String]) {
+ duh(33L)
+ duh(3.0d)
+ foo.bar.duh(33L)
+ foo.bar.duh(3.0d)
+ buh(66L)
+ buh(6.0d)
+ foo.bar.buh(66L)
+ foo.bar.buh(6.0d)
+ }
+ }
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ foo.bar.Main.main(null)
+ }
+}