From 66a3623d59a261830076c7ad2b04fbb82e415547 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 13 Jan 2012 13:32:56 -0800 Subject: 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 (n: Long)Unit Review by @odersky. --- test/files/run/t1987.scala | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 test/files/run/t1987.scala (limited to 'test/files/run/t1987.scala') 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) + } +} -- cgit v1.2.3