From c8fbba0fd3149dc5642e6d56c4176244b55046fd Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 24 Feb 2013 15:40:42 +0100 Subject: Check named-args-for-clarity incur no extra bytecode When named arguments correspond the the parameter declaration order, the compiler should not lift out assignments before the method call, as it would have to do for out-of-order arguments. Confirm this with a bytecode comparison test. --- test/files/jvm/named-args-in-order/SameBytecode.scala | 9 +++++++++ test/files/jvm/named-args-in-order/Test.scala | 10 ++++++++++ 2 files changed, 19 insertions(+) create mode 100644 test/files/jvm/named-args-in-order/SameBytecode.scala create mode 100644 test/files/jvm/named-args-in-order/Test.scala (limited to 'test/files/jvm/named-args-in-order') diff --git a/test/files/jvm/named-args-in-order/SameBytecode.scala b/test/files/jvm/named-args-in-order/SameBytecode.scala new file mode 100644 index 0000000000..c00641777e --- /dev/null +++ b/test/files/jvm/named-args-in-order/SameBytecode.scala @@ -0,0 +1,9 @@ +class SameBytecode { + def foo(a: Int, b: String) = 0 + def foo(a: Int, b: Any) = 0 + + def a = foo(0, "") + def b = foo(a = 0, "") + def c = foo(0, b = "") + def d = foo(a = 0, b = "") +} \ No newline at end of file diff --git a/test/files/jvm/named-args-in-order/Test.scala b/test/files/jvm/named-args-in-order/Test.scala new file mode 100644 index 0000000000..36b9cbc1d1 --- /dev/null +++ b/test/files/jvm/named-args-in-order/Test.scala @@ -0,0 +1,10 @@ +import scala.tools.partest.BytecodeTest + +object Test extends BytecodeTest { + def show: Unit = { + val classNode = loadClassNode("SameBytecode") + def sameAsA(meth: String) = + sameBytecode(getMethod(classNode, "a"), getMethod(classNode, meth)) + Seq("b", "c", "d").foreach(sameAsA) + } +} -- cgit v1.2.3