summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2016-11-21 13:27:16 +0100
committerIulian Dragos <jaguarul@gmail.com>2016-11-25 10:50:57 +0100
commit7602f2ebc0fbd0e1b51aa8d9d9a9e71607a06dd6 (patch)
treec602918cdd2b542cae758019ae43aa90bb8af7f1 /test
parentd5f21af9f41d8f4bd22ee6126e1476b4a76c51c2 (diff)
downloadscala-7602f2ebc0fbd0e1b51aa8d9d9a9e71607a06dd6.tar.gz
scala-7602f2ebc0fbd0e1b51aa8d9d9a9e71607a06dd6.tar.bz2
scala-7602f2ebc0fbd0e1b51aa8d9d9a9e71607a06dd6.zip
SI-10071 Separate compilation for varargs methods
Make sure that methods annotated with varargs are properly mixed-in. This commit splits the transformation into an info transformer (that works on all symbols, whether they come from source or binary) and a tree transformer. The gist of this is that the symbol-creation part of the code was moved to the UnCurry info transformer, while tree operations remained in the tree transformer. The newly created symbol is attached to the original method so that the tree transformer can still retrieve the symbol. A few fall outs: - I removed a local map that was identical to TypeParamsVarargsAttachment - moved the said attachment to StdAttachments so it’s visible between reflect.internal and nsc.transform - a couple more comments in UnCurry to honour the boy-scout rule
Diffstat (limited to 'test')
-rw-r--r--test/files/jvm/varargs-separate-bytecode.check1
-rw-r--r--test/files/jvm/varargs-separate-bytecode/AbstractProps_1.scala8
-rw-r--r--test/files/jvm/varargs-separate-bytecode/Props_2.scala3
-rw-r--r--test/files/jvm/varargs-separate-bytecode/Test.scala15
-rw-r--r--test/files/run/t5125b.check3
-rw-r--r--test/files/run/t5125b.scala12
6 files changed, 42 insertions, 0 deletions
diff --git a/test/files/jvm/varargs-separate-bytecode.check b/test/files/jvm/varargs-separate-bytecode.check
new file mode 100644
index 0000000000..1507cd48c5
--- /dev/null
+++ b/test/files/jvm/varargs-separate-bytecode.check
@@ -0,0 +1 @@
+Found vararg overload for method create \ No newline at end of file
diff --git a/test/files/jvm/varargs-separate-bytecode/AbstractProps_1.scala b/test/files/jvm/varargs-separate-bytecode/AbstractProps_1.scala
new file mode 100644
index 0000000000..5dfb8d1a9e
--- /dev/null
+++ b/test/files/jvm/varargs-separate-bytecode/AbstractProps_1.scala
@@ -0,0 +1,8 @@
+package foo
+
+import scala.annotation.varargs
+
+trait AbstractProps {
+ @varargs
+ def create(x: String, y: Int*): AbstractProps = null
+}
diff --git a/test/files/jvm/varargs-separate-bytecode/Props_2.scala b/test/files/jvm/varargs-separate-bytecode/Props_2.scala
new file mode 100644
index 0000000000..3fc09586fc
--- /dev/null
+++ b/test/files/jvm/varargs-separate-bytecode/Props_2.scala
@@ -0,0 +1,3 @@
+import foo.AbstractProps
+
+class Props extends AbstractProps \ No newline at end of file
diff --git a/test/files/jvm/varargs-separate-bytecode/Test.scala b/test/files/jvm/varargs-separate-bytecode/Test.scala
new file mode 100644
index 0000000000..a666de7f39
--- /dev/null
+++ b/test/files/jvm/varargs-separate-bytecode/Test.scala
@@ -0,0 +1,15 @@
+import scala.collection.JavaConverters._
+import scala.tools.asm
+import scala.tools.asm.Opcodes
+import scala.tools.partest.BytecodeTest
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val classNode = loadClassNode("Props")
+ val methods = classNode.methods.iterator().asScala.filter( m => m.name == "create")
+
+ for (m <- methods if (m.access & Opcodes.ACC_VARARGS) > 0) {
+ println(s"Found vararg overload for method ${m.name}")
+ }
+ }
+}
diff --git a/test/files/run/t5125b.check b/test/files/run/t5125b.check
index ddbf908f04..29b438a2d6 100644
--- a/test/files/run/t5125b.check
+++ b/test/files/run/t5125b.check
@@ -5,3 +5,6 @@ public void C2.f(scala.collection.Seq)
public void C2$C3.f(java.lang.String[])
public void C2$C3.f(scala.collection.Seq)
public void C4.f(scala.collection.Seq)
+private void C5.f(int,int[])
+private void C5.f(int,scala.collection.Seq)
+public void C5.f(scala.collection.Seq)
diff --git a/test/files/run/t5125b.scala b/test/files/run/t5125b.scala
index 149c49e213..60ab1d9792 100644
--- a/test/files/run/t5125b.scala
+++ b/test/files/run/t5125b.scala
@@ -23,6 +23,17 @@ class C4 {
}
}
+class C5 {
+ def f(values: String*) = println("Calling C5.f(): " + values)
+ @scala.annotation.varargs
+ private def f(v: Int, values: Int*) = println("Calling C5.f(): " + values)
+
+ def method(): Unit = {
+ @scala.annotation.varargs
+ def f(values: String*) = println("Calling C5.<locally>.f(): " + values)
+ }
+}
+
object Test extends App {
def check(c: Class[_]) {
val methodName = "f"
@@ -34,4 +45,5 @@ object Test extends App {
check(classOf[C2])
check(classOf[C2#C3])
check(classOf[C4])
+ check(classOf[C5])
}