Aladdin - Scala Bugtracking
[#173] project: specification priority: medium category: bug
submitter assigned to status date submitted
Matthias Martin won't fix 2003-10-02 11:34:37.0
subject Local type inference and overloading resolution
code
object V with Executable {
  def foo[A](x: String) = new Object;
  def foo[A](x: Runnable) = new Object;
  val code = foo[Int]("test");
}
what happened
The compiler yields the following error message:
V.scala:4: ambiguous reference to overloaded definition,
both method foo: [A](java.lang.String)scala.Object
and  method foo: [A](java.lang.Runnable)scala.Object
match polymorphic function with 1 parameters
        val code = foo[Int]("test");
                      ^
one error found
The program above works if the type parameter of foo is inferred (i.e. not explicitly given).
what expected Compiler, runtime positive.
[back to overview]
Changes of this bug report
Martin  edited on  2003-10-06 11:03:15.0
The spec currently prescribes this behavior. I am not sure how to write a better spec that avoids this case.