From cac52ac3e3bd34dfc6540968c30d3e861799f9e4 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 6 Aug 2012 21:53:42 +0200 Subject: SI-6199 unit-returning methods now return unit Since Scala reflection relies on Java reflection to perform member invocations, it inherits some of the quirks of the underlying platform. One of such quirks is returning null when invoking a void-returning method. This is now fixed by introducing a check after calling invoke. --- test/files/run/reflection-magicsymbols-invoke.check | 2 +- test/files/run/t6199-mirror.check | 1 + test/files/run/t6199-mirror.scala | 7 +++++++ test/files/run/t6199-toolbox.check | 1 + test/files/run/t6199-toolbox.scala | 8 ++++++++ 5 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/files/run/t6199-mirror.check create mode 100644 test/files/run/t6199-mirror.scala create mode 100644 test/files/run/t6199-toolbox.check create mode 100644 test/files/run/t6199-toolbox.scala (limited to 'test/files') diff --git a/test/files/run/reflection-magicsymbols-invoke.check b/test/files/run/reflection-magicsymbols-invoke.check index a180ed806e..674716adfe 100644 --- a/test/files/run/reflection-magicsymbols-invoke.check +++ b/test/files/run/reflection-magicsymbols-invoke.check @@ -68,7 +68,7 @@ testing Object.==: true testing Object.clone: class java.lang.CloneNotSupportedException: java.lang.String testing Object.eq: true testing Object.equals: true -testing Object.finalize: null +testing Object.finalize: () testing Object.getClass: class java.lang.String testing Object.hashCode: 50 testing Object.ne: false diff --git a/test/files/run/t6199-mirror.check b/test/files/run/t6199-mirror.check new file mode 100644 index 0000000000..ec969b5b93 --- /dev/null +++ b/test/files/run/t6199-mirror.check @@ -0,0 +1 @@ +() diff --git a/test/files/run/t6199-mirror.scala b/test/files/run/t6199-mirror.scala new file mode 100644 index 0000000000..772a384542 --- /dev/null +++ b/test/files/run/t6199-mirror.scala @@ -0,0 +1,7 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} + +object Test extends App { + class C { def foo = () } + println(cm.reflect(new C).reflectMethod(typeOf[C].member(newTermName("foo")).asMethod)()) +} \ No newline at end of file diff --git a/test/files/run/t6199-toolbox.check b/test/files/run/t6199-toolbox.check new file mode 100644 index 0000000000..ec969b5b93 --- /dev/null +++ b/test/files/run/t6199-toolbox.check @@ -0,0 +1 @@ +() diff --git a/test/files/run/t6199-toolbox.scala b/test/files/run/t6199-toolbox.scala new file mode 100644 index 0000000000..14670f8e21 --- /dev/null +++ b/test/files/run/t6199-toolbox.scala @@ -0,0 +1,8 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + val tb = cm.mkToolBox() + println(tb.runExpr(Literal(Constant(())))) +} \ No newline at end of file -- cgit v1.2.3