Aladdin - Scala Bugtracking
[#514] project: compiler priority: low category: bug
submitter assigned to status date submitted
Gilles Martin fixed 2006-01-16 18:54:40.0
subject Auto-application of "()" to function fails when overriden
code
object Test extends Application {
  object Truc {
    override def toString() = "oui"
    def toString(bool: Boolean) = "chaispas"
  }
  val tata: String = Truc.toString
}
what happened
error: ambiguous reference to overloaded definition,
both method toString in object Truc of type (scala.Boolean)java.lang.String
and  method toString in object Truc of type ()java.lang.String
match expected type java.lang.String
  val tata: String = Truc.toString
                         ^
what expected

Scala2 should auto-apply the only method parameters that it can (with the new Scala2 conversion feature), namely the empty one.

I suppose this error could also be seen as a feature: in case of doubt about what to apply, Scala barks. But I think this is not the behaviour that one would expect: I want to be able to call empty-parameters method without "()" anytime, not only in special cases, otherwise it's more a pain than a help (IMHO).

[back to overview]
Changes of this bug report
Martin  edited on  2006-01-20 18:47:59.0