From edadc01df2cbac2c8a00c2e0cc520713690418b9 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Tue, 28 Jan 2014 10:27:59 +0300 Subject: SI-6379 adds MethodSymbol.exception MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- test/files/run/t6379/Macros_1.scala | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/files/run/t6379/Macros_1.scala (limited to 'test/files/run/t6379/Macros_1.scala') diff --git a/test/files/run/t6379/Macros_1.scala b/test/files/run/t6379/Macros_1.scala new file mode 100644 index 0000000000..a866438f7d --- /dev/null +++ b/test/files/run/t6379/Macros_1.scala @@ -0,0 +1,26 @@ +import scala.reflect.macros.whitebox._ +import scala.language.experimental.macros +import java.io._ + +object Macros { + def impl(c: Context) = { + var messages = List[String]() + def println(msg: String) = messages :+= msg + + import c.universe._ + def test(sym: MethodSymbol): Unit = { + println(s"uninitialized ${sym.name}: ${sym.exceptions}") + sym.typeSignature + println(s"initialized ${sym.name}: ${sym.exceptions}") + } + + println("compile-time") + test(typeOf[Closeable].declaration(TermName("close")).asMethod) + test(typeOf[Product1[_]].declaration(TermName("productElement")).asMethod) + test(c.mirror.staticClass("Reader").typeSignature.declaration(TermName("read")).asMethod) + + q"..${messages.map(msg => q"println($msg)")}" + } + + def foo: Any = macro impl +} \ No newline at end of file -- cgit v1.2.3