summaryrefslogtreecommitdiff
path: root/test/files/run/t7008-scala-defined
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-02-04 22:23:54 +0100
committerEugene Burmako <xeno.by@gmail.com>2013-02-04 22:23:54 +0100
commit02dd4c974f33d137ea353a72e27efb70928fb378 (patch)
tree277283b686506db7f237a662de3e375347190bda /test/files/run/t7008-scala-defined
parent0bcdf71a96d6d0b6276801efbe49081f0ae7749d (diff)
downloadscala-02dd4c974f33d137ea353a72e27efb70928fb378.tar.gz
scala-02dd4c974f33d137ea353a72e27efb70928fb378.tar.bz2
scala-02dd4c974f33d137ea353a72e27efb70928fb378.zip
reflecting @throws defined in Scala code
As per Jason's comment: How are Scala classes containing @throws annots treated? I can't figure out whether we pickle the annotation in addition to adding the exception to the signature. If we do, might we end up with duplicate annotations in runtime reflection? This warrants a test. See the context of the discussion here: https://github.com/scala/scala/pull/2040/files#r2874769. No, we won't end up with duplicates, because classes defined in Scala are loaded in a different completer. But I'll add a test - you can never have too many of those.
Diffstat (limited to 'test/files/run/t7008-scala-defined')
-rw-r--r--test/files/run/t7008-scala-defined/Impls_Macros_2.scala12
-rw-r--r--test/files/run/t7008-scala-defined/ScalaClassWithCheckedExceptions_1.scala6
-rw-r--r--test/files/run/t7008-scala-defined/Test_3.scala9
3 files changed, 27 insertions, 0 deletions
diff --git a/test/files/run/t7008-scala-defined/Impls_Macros_2.scala b/test/files/run/t7008-scala-defined/Impls_Macros_2.scala
new file mode 100644
index 0000000000..94fd99018e
--- /dev/null
+++ b/test/files/run/t7008-scala-defined/Impls_Macros_2.scala
@@ -0,0 +1,12 @@
+import language.experimental.macros
+import scala.reflect.macros.Context
+
+object Macros {
+ def impl(c: Context) = {
+ val decls = c.typeOf[ScalaClassWithCheckedExceptions_1[_]].declarations.toList
+ val s = decls.sortBy(_.name.toString).map(decl => (s"${decl.name}: ${decl.annotations}")).mkString(scala.compat.Platform.EOL)
+ c.universe.reify(println(c.literal(s).splice))
+ }
+
+ def foo = macro impl
+} \ No newline at end of file
diff --git a/test/files/run/t7008-scala-defined/ScalaClassWithCheckedExceptions_1.scala b/test/files/run/t7008-scala-defined/ScalaClassWithCheckedExceptions_1.scala
new file mode 100644
index 0000000000..7783c873ec
--- /dev/null
+++ b/test/files/run/t7008-scala-defined/ScalaClassWithCheckedExceptions_1.scala
@@ -0,0 +1,6 @@
+class ScalaClassWithCheckedExceptions_1[E1 <: Exception] @throws[NullPointerException]("") () {
+ @throws[E1]("") def bar() {}
+ @throws[IllegalStateException]("") def baz(x: Int) {}
+ // FIXME: SI-7066
+ // @throws[E2]("") def foo[E2 <: Exception] {}
+} \ No newline at end of file
diff --git a/test/files/run/t7008-scala-defined/Test_3.scala b/test/files/run/t7008-scala-defined/Test_3.scala
new file mode 100644
index 0000000000..03bb79d311
--- /dev/null
+++ b/test/files/run/t7008-scala-defined/Test_3.scala
@@ -0,0 +1,9 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ Macros.foo
+ println("=============")
+
+ val decls = typeOf[ScalaClassWithCheckedExceptions_1[_]].declarations.toList
+ decls sortBy (_.name.toString) foreach (decl => println(s"${decl.name}: ${decl.annotations}"))
+} \ No newline at end of file