From f6a4d945698bac9b64a2d2ddaf44eb7302336670 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Mon, 21 May 2012 11:41:23 -0700 Subject: 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. --- test/files/run/t3761-overload-byname.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/files/run/t3761-overload-byname.scala (limited to 'test/files/run/t3761-overload-byname.scala') 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")) + } +} -- cgit v1.2.3