summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala8
-rw-r--r--test/files/jvm/t3003.check1
-rw-r--r--test/files/jvm/t3003/Annot.java4
-rw-r--r--test/files/jvm/t3003/Test_1.scala8
4 files changed, 19 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
index 2c4a1c5b5f..d83659f477 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
@@ -431,8 +431,12 @@ trait TypeKinds { self: ICodes =>
////////////////// Conversions //////////////////////////////
- /** Return the TypeKind of the given type */
- def toTypeKind(t: Type): TypeKind = t match {
+ /** Return the TypeKind of the given type
+ *
+ * Call to .normalize fixes #3003 (follow type aliases). Otherwise,
+ * arrayOrClassType below would return AnyRefReference.
+ */
+ def toTypeKind(t: Type): TypeKind = t.normalize match {
case ThisType(sym) =>
if (sym == ArrayClass)
AnyRefReference
diff --git a/test/files/jvm/t3003.check b/test/files/jvm/t3003.check
new file mode 100644
index 0000000000..c69e389d13
--- /dev/null
+++ b/test/files/jvm/t3003.check
@@ -0,0 +1 @@
+List(List(@Annot(optionType=class java.lang.String)))
diff --git a/test/files/jvm/t3003/Annot.java b/test/files/jvm/t3003/Annot.java
new file mode 100644
index 0000000000..1d5f206fd7
--- /dev/null
+++ b/test/files/jvm/t3003/Annot.java
@@ -0,0 +1,4 @@
+@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
+public @interface Annot {
+ Class<?> optionType();
+}
diff --git a/test/files/jvm/t3003/Test_1.scala b/test/files/jvm/t3003/Test_1.scala
new file mode 100644
index 0000000000..ec7f220c94
--- /dev/null
+++ b/test/files/jvm/t3003/Test_1.scala
@@ -0,0 +1,8 @@
+class C {
+ @Annot(optionType=classOf[String]) val k = 0
+}
+object Test {
+ def main(args: Array[String]) {
+ println(classOf[C].getDeclaredFields.toList.sortBy(f => f.getName).map(f => f.getAnnotations.toList))
+ }
+}