diff options
author | Som Snytt <som.snytt@gmail.com> | 2012-05-21 11:41:23 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2012-05-21 12:31:27 -0700 |
commit | f6a4d945698bac9b64a2d2ddaf44eb7302336670 (patch) | |
tree | 746ddbb88e76085c95348bcb715490a6adb028ee /test/files | |
parent | f406550146250f5a6036d3d778582efa6d68252a (diff) | |
download | scala-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')
-rw-r--r-- | test/files/run/t3761-overload-byname.check | 4 | ||||
-rw-r--r-- | test/files/run/t3761-overload-byname.scala | 18 |
2 files changed, 22 insertions, 0 deletions
diff --git a/test/files/run/t3761-overload-byname.check b/test/files/run/t3761-overload-byname.check new file mode 100644 index 0000000000..9410a4fe65 --- /dev/null +++ b/test/files/run/t3761-overload-byname.check @@ -0,0 +1,4 @@ +hello! +hello working world +goodnight! +goodnight moon, nobody, noises everywhere 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")) + } +} |