summaryrefslogtreecommitdiff
path: root/test/files/run/t6860.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-01-14 23:29:50 -0800
committerPaul Phillips <paulp@improving.org>2013-01-26 11:19:36 -0800
commit832fc9a67e5aa85bdde61883527d3ac9554094d7 (patch)
treeb5bc08f2ef57331efa66c956112bface14cd530f /test/files/run/t6860.scala
parent72f36cbc80d5667c5ada3b7c0fe60435a4b202ad (diff)
downloadscala-832fc9a67e5aa85bdde61883527d3ac9554094d7.tar.gz
scala-832fc9a67e5aa85bdde61883527d3ac9554094d7.tar.bz2
scala-832fc9a67e5aa85bdde61883527d3ac9554094d7.zip
SI-2577, SI-6860: annotation type inference.
This is less than ideal: scala> class Bippy[T] extends annotation.StaticAnnotation defined class Bippy scala> def f: Int @Bippy = 5 f: Int @Bippy[T] Turns out we can infer such types. Now it says: scala> def f: Int @Bippy = 5 f: Int @Bippy[Nothing] This should put to rest many an issue with parameterized annotations.
Diffstat (limited to 'test/files/run/t6860.scala')
-rw-r--r--test/files/run/t6860.scala20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/files/run/t6860.scala b/test/files/run/t6860.scala
new file mode 100644
index 0000000000..2dcc2a67f7
--- /dev/null
+++ b/test/files/run/t6860.scala
@@ -0,0 +1,20 @@
+class Bippy[T](val value: T) extends annotation.StaticAnnotation
+
+class A {
+ @Bippy("hi") def f1: Int = 1
+ @Bippy[String]("hi") def f2: Int = 2
+
+ @throws("what do I throw?") def f3 = throw new RuntimeException
+ @throws[RuntimeException]("that's good to know!") def f4 = throw new RuntimeException
+}
+
+object Test {
+ import scala.reflect.runtime.universe._
+
+ def main(args: Array[String]): Unit = {
+ val members = typeOf[A].declarations.toList
+ val tpes = members flatMap (_.annotations) map (_.tpe)
+
+ tpes.map(_.toString).sorted foreach println
+ }
+}