Simple implementation of a dynamic object (using 2.10.0-M3):
import language.dynamics
object D extends Dynamic {
def selectDynamic( field : String ) = Symbol( field )
}
The following works fine and as expected
object DynamicTest extends App {
println( D.a )
}
Print 'a
But if I try this:
object DynamicTest extends App {
println( D.x )
}
I get nasty errors:
[error] DynProb.scala:7: type mismatch;
[error] found : D.type
[error] required: ?{val x: ?}
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error] both method any2Ensuring in object Predef of type [A](x: A)Ensuring[A]
[error] and method any2ArrowAssoc in object Predef of type [A](x: A)ArrowAssoc[A]
[error] are possible conversion functions from D.type to ?{val x: ?}
[error] println( D.x )
[error] ^
[error] one error found
Why is x so special? Am I doing something stupid?
source
share