diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/reflect/ToolBoxFactory.scala | 3 | ||||
-rw-r--r-- | src/reflect/scala/reflect/runtime/JavaMirrors.scala | 12 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala index 9987931cf3..eeec973299 100644 --- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala +++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala @@ -256,7 +256,8 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => // } val (singleton, jmeth) = compileExpr(expr) val result = jmeth.invoke(singleton, thunks map (_.asInstanceOf[AnyRef]): _*) - result + if (jmeth.getReturnType == java.lang.Void.TYPE) () + else result } def parseExpr(code: String): Tree = { diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index d671225c37..e48c933584 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -280,19 +280,25 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym jmeth } + def jinvoke(jmeth: jMethod, receiver: Any, args: Seq[Any]): Any = { + val result = jmeth.invoke(receiver, args.asInstanceOf[Seq[AnyRef]]: _*) + if (jmeth.getReturnType == java.lang.Void.TYPE) () + else result + } + override def toString = s"method mirror for ${showMethodSig(symbol)} (bound to $receiver)" } private class JavaVanillaMethodMirror(val receiver: Any, symbol: MethodSymbol) extends JavaMethodMirror(symbol) { - def apply(args: Any*): Any = jmeth.invoke(receiver, args.asInstanceOf[Seq[AnyRef]]: _*) + def apply(args: Any*): Any = jinvoke(jmeth, receiver, args) } private class JavaByNameMethodMirror(val receiver: Any, symbol: MethodSymbol) extends JavaMethodMirror(symbol) { def apply(args: Any*): Any = { val transformed = map2(args.toList, symbol.params.flatten)((arg, param) => if (isByNameParamType(param.info)) () => arg else arg) - jmeth.invoke(receiver, transformed.asInstanceOf[Seq[AnyRef]]: _*) + jinvoke(jmeth, receiver, transformed) } } @@ -321,7 +327,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym def invokeMagicPrimitiveMethod = { val jmeths = classOf[BoxesRunTime].getDeclaredMethods.filter(_.getName == nme.primitiveMethodName(symbol.name).toString) assert(jmeths.length == 1, jmeths.toList) - jmeths.head.invoke(null, (objReceiver +: objArgs): _*) + jinvoke(jmeths.head, null, objReceiver +: objArgs) } symbol match { |