blob: bf639260e77a240696717ca1a9f003a6a655e1d8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
scala> :power
Power mode enabled. :phase is at typer.
import scala.tools.nsc._, intp.global._, definitions._
Try :help or completions for vals._ and power._
scala> :paste
// Entering paste mode (ctrl-D to finish)
{
val clazz = rootMirror.getClassByName(newTermName("test.ThrowsDeclaration_2"));
{
val method = clazz.info.member(newTermName("foo"))
val throwsAnn = method.annotations.head
val atp = throwsAnn.atp
println("foo")
println("atp.typeParams.isEmpty: " + atp.typeParams.isEmpty)
println(throwsAnn)
}
println
{
val method = clazz.info.member(newTermName("bar"))
val throwsAnn = method.annotations.head
val Literal(const) = throwsAnn.args.head
val tp = const.typeValue
println("bar")
println("tp.typeParams.isEmpty: " + tp.typeParams.isEmpty)
println(throwsAnn)
}
}
// Exiting paste mode, now interpreting.
foo
atp.typeParams.isEmpty: true
throws[IllegalStateException](classOf[java.lang.IllegalStateException])
bar
tp.typeParams.isEmpty: true
throws[test.PolymorphicException[_]](classOf[test.PolymorphicException])
scala> :quit
|