diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/applydynamic_sip.check | 8 | ||||
-rw-r--r-- | test/files/run/dynamic-applyDynamic.check | 14 | ||||
-rw-r--r-- | test/files/run/dynamic-applyDynamic.scala | 26 | ||||
-rw-r--r-- | test/files/run/dynamic-selectDynamic.check | 13 | ||||
-rw-r--r-- | test/files/run/dynamic-selectDynamic.scala | 25 |
5 files changed, 82 insertions, 4 deletions
diff --git a/test/files/neg/applydynamic_sip.check b/test/files/neg/applydynamic_sip.check index dcf97b29fc..b50858356d 100644 --- a/test/files/neg/applydynamic_sip.check +++ b/test/files/neg/applydynamic_sip.check @@ -13,28 +13,28 @@ applydynamic_sip.scala:18: error: type mismatch; error after rewriting to Test.this.bad1.selectDynamic("sel") possible cause: maybe a wrong Dynamic method signature? bad1.sel - ^ + ^ applydynamic_sip.scala:19: error: type mismatch; found : String("sel") required: Int error after rewriting to Test.this.bad1.applyDynamic("sel") possible cause: maybe a wrong Dynamic method signature? bad1.sel(1) - ^ + ^ applydynamic_sip.scala:20: error: type mismatch; found : String("sel") required: Int error after rewriting to Test.this.bad1.applyDynamicNamed("sel") possible cause: maybe a wrong Dynamic method signature? bad1.sel(a = 1) - ^ + ^ applydynamic_sip.scala:21: error: type mismatch; found : String("sel") required: Int error after rewriting to Test.this.bad1.updateDynamic("sel") possible cause: maybe a wrong Dynamic method signature? bad1.sel = 1 - ^ + ^ applydynamic_sip.scala:29: error: Int does not take parameters error after rewriting to Test.this.bad2.selectDynamic("sel") possible cause: maybe a wrong Dynamic method signature? diff --git a/test/files/run/dynamic-applyDynamic.check b/test/files/run/dynamic-applyDynamic.check new file mode 100644 index 0000000000..89a0d55282 --- /dev/null +++ b/test/files/run/dynamic-applyDynamic.check @@ -0,0 +1,14 @@ +[[syntax trees at end of typer]] // newSource1.scala +[0:67]package [0:0]<empty> { + [0:67]object X extends [9:67][67]scala.AnyRef { + [9]def <init>(): [9]X.type = [9]{ + [9][9][9]X.super.<init>(); + [9]() + }; + [17:30]private[this] val d: [21]D = [25:30][25:30][25:30]new [29:30]D(); + [21]<stable> <accessor> def d: [21]D = [21][21]X.this.d; + [37:49][37:38][37:38][37]X.this.d.applyDynamic(<39:45>"method")([46:48]10); + [56:61]<56:57><56:57>[56]X.this.d.applyDynamic(<56:57>"apply")([58:60]10) + } +} + diff --git a/test/files/run/dynamic-applyDynamic.scala b/test/files/run/dynamic-applyDynamic.scala new file mode 100644 index 0000000000..b06041194c --- /dev/null +++ b/test/files/run/dynamic-applyDynamic.scala @@ -0,0 +1,26 @@ +import scala.tools.partest.DirectTest + +object Test extends DirectTest { + + override def extraSettings: String = + s"-usejavacp -Xprint-pos -Xprint:typer -Yrangepos -Ystop-after:typer -d ${testOutput.path}" + + override def code = """ + object X { + val d = new D + d.method(10) + d(10) + } + """.trim + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} + +import language.dynamics +class D extends Dynamic { + def applyDynamic(name: String)(value: Any) = ??? +}
\ No newline at end of file diff --git a/test/files/run/dynamic-selectDynamic.check b/test/files/run/dynamic-selectDynamic.check new file mode 100644 index 0000000000..7f95ed3d19 --- /dev/null +++ b/test/files/run/dynamic-selectDynamic.check @@ -0,0 +1,13 @@ +[[syntax trees at end of typer]] // newSource1.scala +[0:50]package [0:0]<empty> { + [0:50]object X extends [9:50][50]scala.AnyRef { + [9]def <init>(): [9]X.type = [9]{ + [9][9][9]X.super.<init>(); + [9]() + }; + [17:30]private[this] val d: [21]D = [25:30][25:30][25:30]new [29:30]D(); + [21]<stable> <accessor> def d: [21]D = [21][21]X.this.d; + [37:38][37:38][37]X.this.d.selectDynamic(<39:44>"field") + } +} + diff --git a/test/files/run/dynamic-selectDynamic.scala b/test/files/run/dynamic-selectDynamic.scala new file mode 100644 index 0000000000..bd6c138c50 --- /dev/null +++ b/test/files/run/dynamic-selectDynamic.scala @@ -0,0 +1,25 @@ +import scala.tools.partest.DirectTest + +object Test extends DirectTest { + + override def extraSettings: String = + s"-usejavacp -Xprint-pos -Xprint:typer -Yrangepos -Ystop-after:typer -d ${testOutput.path}" + + override def code = """ + object X { + val d = new D + d.field + } + """.trim + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} + +import language.dynamics +class D extends Dynamic { + def selectDynamic(name: String) = ??? +} |