summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2010-01-27 14:12:28 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2010-01-27 14:12:28 +0000
commit71a0d2773e6f11cbe4d2ae7bab9d29caa69196c6 (patch)
treedb203904b2d8cf37b5a4671d3aa14c6c534aa0f4
parentf375f8ac3ef86ba13bad9346bd24ce08e86e2de1 (diff)
downloadscala-71a0d2773e6f11cbe4d2ae7bab9d29caa69196c6.tar.gz
scala-71a0d2773e6f11cbe4d2ae7bab9d29caa69196c6.tar.bz2
scala-71a0d2773e6f11cbe4d2ae7bab9d29caa69196c6.zip
now correctly fix #2868. no review
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala41
-rw-r--r--test/files/pos/t2868/Jann.java5
-rw-r--r--test/files/pos/t2868/Nest.java3
-rw-r--r--test/files/pos/t2868/pick_1.scala7
-rw-r--r--test/files/pos/t2868/test_2.scala6
5 files changed, 42 insertions, 20 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala
index 8258878376..bd1a13187d 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala
@@ -381,26 +381,28 @@ abstract class UnPickler {
/** Read an annotation argument, which is pickled either
* as a Constant or a Tree.
*/
- private def readAnnotArg(): Tree = {
- if (peekByte() == TREE) {
- readTree()
+ private def readAnnotArg(i: Int): Tree = {
+ if (bytes(index(i)) == TREE) {
+ at(i, readTree)
} else {
- val const = readConstant()
+ val const = at(i, readConstant)
Literal(const).setType(const.tpe)
}
}
/** Read a ClassfileAnnotArg (argument to a classfile annotation)
*/
- private def readClassfileAnnotArg(): ClassfileAnnotArg = peekByte() match {
- case ANNOTINFO =>
- NestedAnnotArg(readAnnotation())
- case ANNOTARGARRAY =>
- readByte()
- val end = readNat() + readIndex
- ArrayAnnotArg(until(end, readClassfileAnnotArgRef).toArray)
- case _ =>
- LiteralAnnotArg(readConstant())
+ private def readClassfileAnnotArg(i: Int): ClassfileAnnotArg = bytes(index(i)) match {
+ case ANNOTINFO =>
+ NestedAnnotArg(at(i, readAnnotation))
+ case ANNOTARGARRAY =>
+ at(i, () => {
+ readByte() // skip the `annotargarray` tag
+ val end = readNat() + readIndex
+ ArrayAnnotArg(until(end, () => readClassfileAnnotArg(readNat())).toArray)
+ })
+ case _ =>
+ LiteralAnnotArg(at(i, readConstant))
}
/** Read an AnnotationInfo. Not to be called directly, use
@@ -412,10 +414,13 @@ abstract class UnPickler {
val assocs = new ListBuffer[(Name, ClassfileAnnotArg)]
while (readIndex != end) {
val argref = readNat()
- if (isNameEntry(argref))
- assocs += ((at(argref, readName), readClassfileAnnotArgRef))
+ if (isNameEntry(argref)) {
+ val name = at(argref, readName)
+ val arg = readClassfileAnnotArg(readNat())
+ assocs += ((name, arg))
+ }
else
- args += at(argref, readAnnotArg)
+ args += readAnnotArg(argref)
}
AnnotationInfo(atp, args.toList, assocs.toList)
}
@@ -726,10 +731,6 @@ abstract class UnPickler {
private def readSymbolRef(): Symbol = at(readNat(), readSymbol)
private def readTypeRef(): Type = at(readNat(), readType)
private def readConstantRef(): Constant = at(readNat(), readConstant)
- private def readAnnotArgRef(): Tree =
- at(readNat(), readAnnotArg)
- private def readClassfileAnnotArgRef(): ClassfileAnnotArg =
- at(readNat(), readClassfileAnnotArg)
private def readAnnotationRef(): AnnotationInfo =
at(readNat(), readAnnotation)
private def readModifiersRef(): Modifiers =
diff --git a/test/files/pos/t2868/Jann.java b/test/files/pos/t2868/Jann.java
new file mode 100644
index 0000000000..f5b68de7b0
--- /dev/null
+++ b/test/files/pos/t2868/Jann.java
@@ -0,0 +1,5 @@
+public @interface Jann {
+ public String str();
+ public Nest inn();
+ public int[] arr();
+}
diff --git a/test/files/pos/t2868/Nest.java b/test/files/pos/t2868/Nest.java
new file mode 100644
index 0000000000..53652291ad
--- /dev/null
+++ b/test/files/pos/t2868/Nest.java
@@ -0,0 +1,3 @@
+public @interface Nest {
+ public int value();
+}
diff --git a/test/files/pos/t2868/pick_1.scala b/test/files/pos/t2868/pick_1.scala
new file mode 100644
index 0000000000..e91728ec2f
--- /dev/null
+++ b/test/files/pos/t2868/pick_1.scala
@@ -0,0 +1,7 @@
+class ann(s: String) extends StaticAnnotation
+class pick {
+ final val s = "bang!"
+ @ann("bang!") def foo = 1
+ @Jann(str = "bang!", inn = new Nest(1), arr = Array(1, 2)) def bar = 2
+ @Jann(str = "bang!", inn = new Nest(1), arr = Array(1, 2)) def baz = 3
+}
diff --git a/test/files/pos/t2868/test_2.scala b/test/files/pos/t2868/test_2.scala
new file mode 100644
index 0000000000..f11ef0fae2
--- /dev/null
+++ b/test/files/pos/t2868/test_2.scala
@@ -0,0 +1,6 @@
+class test {
+ val l = (new pick).s
+ val u = (new pick).foo
+ val c = (new pick).bar
+ val k = (new pick).baz
+}