summaryrefslogtreecommitdiff
path: root/test/files/run/t1987.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-01-13 13:32:56 -0800
committerPaul Phillips <paulp@improving.org>2012-01-13 13:48:12 -0800
commit66a3623d59a261830076c7ad2b04fbb82e415547 (patch)
tree8e1d0ca2ae15e6b753b2c8c47ddcaac48ec1dd86 /test/files/run/t1987.scala
parentb0de5f13329aa24752fae079c50cc0584471379e (diff)
downloadscala-66a3623d59a261830076c7ad2b04fbb82e415547.tar.gz
scala-66a3623d59a261830076c7ad2b04fbb82e415547.tar.bz2
scala-66a3623d59a261830076c7ad2b04fbb82e415547.zip
Fixed overloading in package objects.
Implementing a warning for the behavior described in SI-1987 gave me enough of a foot in the door to fix it rather than warning about it. I suppose this is a variation of rubber ducky debugging. % scalac -Ylog:typer test/files/run/t1987.scala [log typer] !!! Overloaded package object member resolved incorrectly. Discarded: def duh(n: Double): Unit Using: val duh: (n: Double)Unit <and> (n: Long)Unit Review by @odersky.
Diffstat (limited to 'test/files/run/t1987.scala')
-rw-r--r--test/files/run/t1987.scala62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/files/run/t1987.scala b/test/files/run/t1987.scala
new file mode 100644
index 0000000000..4c278ec6a0
--- /dev/null
+++ b/test/files/run/t1987.scala
@@ -0,0 +1,62 @@
+// a.scala
+// Fri Jan 13 11:31:47 PST 2012
+
+package foo {
+ package object bar {
+ def duh(n: Long) = println("long")
+ def duh(n: Double) = println("double")
+
+ def duh2(n: Double) = println("double")
+ def duh2(n: Long) = println("long")
+ }
+ package bar {
+ object Main {
+ def main(args:Array[String]) {
+ duh(33L)
+ bip.bar.duh(33L)
+ duh(33d)
+ bip.bar.duh(33d)
+
+ duh2(33L)
+ bip.bar.duh2(33L)
+ duh2(33d)
+ bip.bar.duh2(33d)
+ }
+ }
+ }
+}
+
+package bip {
+ trait Duh {
+ def duh(n: Long) = println("long")
+ def duh(n: Double) = println("double")
+ }
+ trait Duh2 {
+ def duh2(n: Double) = println("double")
+ def duh2(n: Long) = println("long")
+ }
+
+ package object bar extends Duh with Duh2 { }
+ package bar {
+ object Main {
+ def main(args:Array[String]) {
+ duh(33L)
+ bip.bar.duh(33L)
+ duh(33d)
+ bip.bar.duh(33d)
+
+ duh2(33L)
+ bip.bar.duh2(33L)
+ duh2(33d)
+ bip.bar.duh2(33d)
+ }
+ }
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ foo.bar.Main.main(null)
+ bip.bar.Main.main(null)
+ }
+}