summaryrefslogtreecommitdiff
path: root/test/files/run/t6355.scala
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-12-28 02:25:29 +0300
committerEugene Burmako <xeno.by@gmail.com>2013-12-28 02:25:29 +0300
commit431e19f9f1a5b62e361579bac6fd321c6c3018d2 (patch)
tree5e8ca4a9d08ec83b678cfe7abf97134fc1411781 /test/files/run/t6355.scala
parent9f0594c57716ed551918e15be6da843982e8ba12 (diff)
downloadscala-431e19f9f1a5b62e361579bac6fd321c6c3018d2.tar.gz
scala-431e19f9f1a5b62e361579bac6fd321c6c3018d2.tar.bz2
scala-431e19f9f1a5b62e361579bac6fd321c6c3018d2.zip
SI-6355 SI-7059 it is possible to overload applyDynamic
As our discussion at https://issues.scala-lang.org/browse/SI-6355 shows, it looks like it is possible to overload applyDynamic, even though a straightforward way is closed. This commit codifies the pattern proposed by @paulp and makes sure that it doesn’t break in the future.
Diffstat (limited to 'test/files/run/t6355.scala')
-rw-r--r--test/files/run/t6355.scala17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/files/run/t6355.scala b/test/files/run/t6355.scala
new file mode 100644
index 0000000000..f1921391a3
--- /dev/null
+++ b/test/files/run/t6355.scala
@@ -0,0 +1,17 @@
+import scala.language.dynamics
+
+class A extends Dynamic {
+ def applyDynamic(method: String): B = new B(method)
+}
+class B(method: String) {
+ def apply(x: Int) = s"$method(x: Int) called with x = $x"
+ def apply(x: String) = s"""$method(x: String) called with x = "$x""""
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ val x = new A
+ println(x.bippy(42))
+ println(x.bippy("42"))
+ }
+}