Skip to content

Instantly share code, notes, and snippets.

@rudogma
Last active May 30, 2017 19:33
Show Gist options
  • Save rudogma/95ba5a9b8f494f1a6ab4eb9a70b9b66e to your computer and use it in GitHub Desktop.
Save rudogma/95ba5a9b8f494f1a6ab4eb9a70b9b66e to your computer and use it in GitHub Desktop.
Danger! High voltage!
import scala.language.dynamics
object Test extends App {
implicit class MyVal[T](val value:T) extends AnyVal
class Test1 extends Dynamic {
def selectDynamic(field:String):String = "Hello"
}
class Test2
val go = new Test1
println("go: "+go.value)
val go2 = new Test2
println("go2: "+go2.value)
}
// Конечно это не баг, а следствие спецификации и приоритетов в ней( в случае selectDynamic).
// Однако не самое желательное поведение
go: tests.exp.Test$Test1@4cb2c100
go2: tests.exp.Test$Test2@47f6473
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment