summaryrefslogtreecommitdiff
path: root/test/files/run/t3761-overload-byname.scala
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2012-05-21 11:41:23 -0700
committerSom Snytt <som.snytt@gmail.com>2012-05-21 12:31:27 -0700
commitf6a4d945698bac9b64a2d2ddaf44eb7302336670 (patch)
tree746ddbb88e76085c95348bcb715490a6adb028ee /test/files/run/t3761-overload-byname.scala
parentf406550146250f5a6036d3d778582efa6d68252a (diff)
downloadscala-f6a4d945698bac9b64a2d2ddaf44eb7302336670.tar.gz
scala-f6a4d945698bac9b64a2d2ddaf44eb7302336670.tar.bz2
scala-f6a4d945698bac9b64a2d2ddaf44eb7302336670.zip
SI-3761: Overload resolution fails on by-name parameter
When isAsSpecific checks if method m applies to args of types of formal params of m1, a by-name parameter was converted to its underlying result type for the params (of m) but not the args (of m1). This had the useful effect of making m(A) more specific than m(=>A), which is the specified prioritization for implicit views, but also made m(=>A) and m(=>A, B*) ambiguous. To handle this edge case, the isCompatible test for A and =>A is made explicit, and by-name params are no longer converted.
Diffstat (limited to 'test/files/run/t3761-overload-byname.scala')
-rw-r--r--test/files/run/t3761-overload-byname.scala18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/files/run/t3761-overload-byname.scala b/test/files/run/t3761-overload-byname.scala
new file mode 100644
index 0000000000..0e2c9b1059
--- /dev/null
+++ b/test/files/run/t3761-overload-byname.scala
@@ -0,0 +1,18 @@
+
+class OverTheTop {
+ def info0(m: String) = m + "!"
+ def info0(m: String, args: Any*) = m +" "+ args.mkString(" ")
+
+ // as reported
+ def info1(m: =>String) = m + "!"
+ def info1(m: =>String, args: Any*) = m +" "+ args.mkString(", ")
+}
+object Test {
+ def main(args: Array[String]) {
+ val top = new OverTheTop
+ println(top.info0("hello"))
+ println(top.info0("hello","working","world"))
+ println(top.info1("goodnight"))
+ println(top.info1("goodnight", "moon", "nobody", "noises everywhere"))
+ }
+}