summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2007-03-02 08:34:30 +0000
committermihaylov <mihaylov@epfl.ch>2007-03-02 08:34:30 +0000
commit614ebd7eea86f1e83052638acde0c24c8d47b619 (patch)
treec7bac3128313a7f0c2af79e780c799906f9f1048
parent32176ac4d37daeb235d622d4c4081b7b0fdb43f6 (diff)
downloadscala-614ebd7eea86f1e83052638acde0c24c8d47b619.tar.gz
scala-614ebd7eea86f1e83052638acde0c24c8d47b619.tar.bz2
scala-614ebd7eea86f1e83052638acde0c24c8d47b619.zip
Fixed a problem with the application of Java an...
Fixed a problem with the application of Java annotations with default values
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
-rw-r--r--test/files/jvm5/SourceAnnotation.java4
-rw-r--r--test/files/jvm5/attributes.check4
-rw-r--r--test/files/jvm5/attributes.scala13
-rw-r--r--test/files/lib/annotations.jar.desired.sha12
6 files changed, 19 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index 40012423a9..4022c475d2 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -661,7 +661,7 @@ abstract class ClassfileParser {
in.skip(attrLen)
}
}
- def parseTaggedConstant(): Constant = {
+ def parseTaggedConstant: Constant = {
val tag = in.nextByte
val index = in.nextChar
tag match {
@@ -685,7 +685,7 @@ abstract class ClassfileParser {
case ARRAY_TAG =>
val arr = new ArrayBuffer[Constant]()
for (val i <- 0 until index) {
- arr += parseTaggedConstant()
+ arr += parseTaggedConstant
}
new ArrayConstant(arr.toArray,
appliedType(definitions.ArrayClass.typeConstructor, List(arr(0).tpe)))
@@ -700,7 +700,7 @@ abstract class ClassfileParser {
val nvpairs = new ListBuffer[(Name,Constant)]
for (val i <- 0 until nargs) {
val name = pool.getName(in.nextChar)
- nvpairs += (name, parseTaggedConstant())
+ nvpairs += (name, parseTaggedConstant)
}
sym.attributes = AttrInfo(attrType, List(), nvpairs.toList) :: sym.attributes
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 4c921da9c2..fbf78cbe7d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1602,7 +1602,7 @@ trait Typers requires Analyzer {
}
}
for (val name <- names) {
- if (!name.attributes.contains((AnnotationDefaultAttr.tpe, List(), List()))) {
+ if (!name.attributes.contains(AttrInfo(AnnotationDefaultAttr.tpe, List(), List()))) {
error(constr.pos, "attribute " + annType.symbol.fullNameString + " is missing element " + name.name)
}
}
diff --git a/test/files/jvm5/SourceAnnotation.java b/test/files/jvm5/SourceAnnotation.java
index a124ee3ee1..36725aa5b6 100644
--- a/test/files/jvm5/SourceAnnotation.java
+++ b/test/files/jvm5/SourceAnnotation.java
@@ -4,6 +4,6 @@ import java.lang.annotation.*;
@Retention(value=RetentionPolicy.RUNTIME)
public @interface SourceAnnotation {
- public String url();
- public String mail();
+ public String value();
+ public String mail() default "bill.gates@bloodsuckers.com";
}
diff --git a/test/files/jvm5/attributes.check b/test/files/jvm5/attributes.check
index c0cc0aee03..06d35ddb48 100644
--- a/test/files/jvm5/attributes.check
+++ b/test/files/jvm5/attributes.check
@@ -1,4 +1,6 @@
class java.rmi.RemoteException
class java.io.IOException
@java.lang.Deprecated()
-@test.SourceAnnotation(url=http://scala.epfl.ch, mail=scala@lists.epfl.ch)
+@test.SourceAnnotation(mail=scala@lists.epfl.ch, value=http://scala.epfl.ch)
+@test.SourceAnnotation(mail=you@bloodsuckers.com, value=http://bloodsuckers.com)
+@test.SourceAnnotation(mail=bill.gates@bloodsuckers.com, value=http://bloodsuckers.com)
diff --git a/test/files/jvm5/attributes.scala b/test/files/jvm5/attributes.scala
index 3e59af28c6..fa5ab1476b 100644
--- a/test/files/jvm5/attributes.scala
+++ b/test/files/jvm5/attributes.scala
@@ -68,11 +68,16 @@ public class Main {
*/
object Test4 {
import test.SourceAnnotation // defined in SourceAnnotation.java
- @SourceAnnotation(){val url = "http://scala.epfl.ch", val mail = "scala@lists.epfl.ch"}
- class Foo
+ @SourceAnnotation{val value = "http://scala.epfl.ch", val mail = "scala@lists.epfl.ch"}
+ class Foo1
+ @SourceAnnotation("http://bloodsuckers.com") { val mail = "you@bloodsuckers.com" }
+ class Foo2
+ @SourceAnnotation("http://bloodsuckers.com")
+ class Foo3
def run: Unit = {
- val clazz = classOf[Foo]
- clazz.getAnnotations foreach Console.println
+ classOf[Foo1].getAnnotations foreach Console.println
+ classOf[Foo2].getAnnotations foreach Console.println
+ classOf[Foo3].getAnnotations foreach Console.println
}
}
diff --git a/test/files/lib/annotations.jar.desired.sha1 b/test/files/lib/annotations.jar.desired.sha1
index d899c93a8c..1600a6cff1 100644
--- a/test/files/lib/annotations.jar.desired.sha1
+++ b/test/files/lib/annotations.jar.desired.sha1
@@ -1 +1 @@
-cda1225f6c63ed896c59c30ba7aa27ce78a54879 ?annotations.jar
+1c8b7d7d273e2a358bd37a36e8b91d656c758467 ?annotations.jar