Implicit Conversion from Any to Dynamic

Why isn't the following working? (Yes, I am working with 2.9.0final and turned the "-Xexperimental" option on.)

implicit def any2Dynamic(a: Any) = new Dynamic {
  def applyDynamic(name: String)(args: Any*) = {
    println(a + name)
  }
}

"Say".hello // value hello is not a member of java.lang.String

One can argue about how meaningful this is... If this would work as expected what precedence will take place at "Say".toInt: StringLike.toInt or (new Dynamic {...}).applyDynamic("toInt")?

8
задан Peter Schmitz 15 May 2011 в 12:31
поделиться