Last active
May 30, 2017 19:33
-
-
Save rudogma/95ba5a9b8f494f1a6ab4eb9a70b9b66e to your computer and use it in GitHub Desktop.
Danger! High voltage!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Конечно это не баг, а следствие спецификации и приоритетов в ней( в случае 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