diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-01-28 10:27:59 +0300 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-02-14 13:24:48 +0100 |
commit | edadc01df2cbac2c8a00c2e0cc520713690418b9 (patch) | |
tree | 5a7211dca95674f85460ee52f167766f0df9348c /test/files/run/t6379/Test_2.scala | |
parent | ad7983b70a43ba9033a491c00ad22691e7a0a7b4 (diff) | |
download | scala-edadc01df2cbac2c8a00c2e0cc520713690418b9.tar.gz scala-edadc01df2cbac2c8a00c2e0cc520713690418b9.tar.bz2 scala-edadc01df2cbac2c8a00c2e0cc520713690418b9.zip |
SI-6379 adds MethodSymbol.exception
Following Simon’s request, this commit introduces a dedicated API
that can be used to acquire the list of exceptions thrown by a method,
abstracting away from whether it’s a Java or a Scala artifact.
Diffstat (limited to 'test/files/run/t6379/Test_2.scala')
-rw-r--r-- | test/files/run/t6379/Test_2.scala | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/files/run/t6379/Test_2.scala b/test/files/run/t6379/Test_2.scala new file mode 100644 index 0000000000..af4ec7c6d0 --- /dev/null +++ b/test/files/run/t6379/Test_2.scala @@ -0,0 +1,22 @@ +import java.io._ +import scala.reflect.runtime.universe._ + +class Reader(fname: String) { + private val in = new BufferedReader(new FileReader(fname)) + @throws[IOException]("if the file doesn't exist") + def read() = in.read() +} + +object Test extends App { + def test(sym: MethodSymbol): Unit = { + println(s"uninitialized ${sym.name}: ${sym.exceptions}") + sym.typeSignature + println(s"initialized ${sym.name}: ${sym.exceptions}") + } + + Macros.foo + println("runtime") + test(typeOf[Closeable].declaration(TermName("close")).asMethod) + test(typeOf[Product1[_]].declaration(TermName("productElement")).asMethod) + test(typeOf[Reader].declaration(TermName("read")).asMethod) +} |