Aladdin - Scala Bugtracking
[#1267] project: compiler priority: low category: missing feature
submitter assigned to status date submitted
Iulian Martin open 2007-08-08 11:30:16.0
subject [contrib #715] Higher-order overloaded methods works bad with implicits
code
object Test {
  implicit def i(n: Int): String = n.toString

  var l: List[Boolean => String] = Nil

  def add(f: Boolean => String) = l = f :: l
  def add(f: (Boolean,Boolean) => String) = l = (f(false,_: Boolean)) :: l

  def test = add((b: Boolean) => 5)
}
what happened
Test.scala:10: error: overloaded method value add with alternatives ((Boolean, Boolean) => String)Unit  ((B\
oolean) => String)Unit cannot be applied to ((Boolean) => Int)
  def test = add((b: Boolean) => 5)
what expected If there is no overloaded method: object Test { implicit def i(n: Int): String = n.toString var l: List[Boolean => String] = Nil def add(f: Boolean => String) = l = f :: l def test = add((b: Boolean) => 5) } then when add is called with a function of type Boolean => Int, scalac finds the implicit def and creates a function of typ Boolean => String. I had expected it to work also with overloaded methods.
[back to overview]
Changes of this bug report
Iulian  edited on  2007-08-08 11:30:41.0
This is probably a won't fix, but I let Martin decide.