Skip to content
Browse files

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.
  • Loading branch information...
1 parent 9179c88 commit c8fbba0fd3149dc5642e6d56c4176244b55046fd @retronym retronym committed with paulp Feb 24, 2013
View
3 test/files/jvm/named-args-in-order.check
@@ -0,0 +1,3 @@
+bytecode identical
+bytecode identical
+bytecode identical
View
9 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 = "")
+}
View
10 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)
+ }
+}

0 comments on commit c8fbba0

Please sign in to comment.
Something went wrong with that request. Please try again.