Skip to content
This repository
Browse code

Test case for SI-7009.

The next commit fixes the problem itself and it's easier to see
in diff what's being fixed exactly.
  • Loading branch information...
commit e22d801a539f951422e91519844c7cb9ce81b413 1 parent c1dd8bb
Grzegorz Kossakowski gkossakowski authored
47 test/files/jvm/throws-annot-from-java.check
... ... @@ -0,0 +1,47 @@
  1 +Type in expressions to have them evaluated.
  2 +Type :help for more information.
  3 +
  4 +scala> :power
  5 +** Power User mode enabled - BEEP WHIR GYVE **
  6 +** :phase has been set to 'typer'. **
  7 +** scala.tools.nsc._ has been imported **
  8 +** global._, definitions._ also imported **
  9 +** Try :help, :vals, power.<tab> **
  10 +
  11 +scala> :paste
  12 +// Entering paste mode (ctrl-D to finish)
  13 +
  14 +{
  15 + val clazz = rootMirror.getClassByName(newTermName("test.ThrowsDeclaration_2"));
  16 + {
  17 + val method = clazz.info.member(newTermName("foo"))
  18 + val throwsAnn = method.annotations.head
  19 + val atp = throwsAnn.atp
  20 + println("foo")
  21 + println("atp.typeParams.isEmpty: " + atp.typeParams.isEmpty)
  22 + println(throwsAnn)
  23 + }
  24 + println
  25 +
  26 + {
  27 + val method = clazz.info.member(newTermName("bar"))
  28 + val throwsAnn = method.annotations.head
  29 + val Literal(const) = throwsAnn.args.head
  30 + val tp = const.typeValue
  31 + println("bar")
  32 + println("tp.typeParams.isEmpty: " + tp.typeParams.isEmpty)
  33 + println(throwsAnn)
  34 + }
  35 +}
  36 +
  37 +// Exiting paste mode, now interpreting.
  38 +
  39 +foo
  40 +atp.typeParams.isEmpty: false
  41 +throws(classOf[java.lang.IllegalStateException])
  42 +
  43 +bar
  44 +tp.typeParams.isEmpty: false
  45 +throws(classOf[test.PolymorphicException])
  46 +
  47 +scala>
3  test/files/jvm/throws-annot-from-java/PolymorphicException_1.scala
... ... @@ -0,0 +1,3 @@
  1 +package test
  2 +
  3 +class PolymorphicException[T] extends Exception
29 test/files/jvm/throws-annot-from-java/Test_3.scala
... ... @@ -0,0 +1,29 @@
  1 +import scala.tools.partest.ReplTest
  2 +
  3 +object Test extends ReplTest {
  4 + def code = """:power
  5 +:paste
  6 +{
  7 + val clazz = rootMirror.getClassByName(newTermName("test.ThrowsDeclaration_2"));
  8 + {
  9 + val method = clazz.info.member(newTermName("foo"))
  10 + val throwsAnn = method.annotations.head
  11 + val atp = throwsAnn.atp
  12 + println("foo")
  13 + println("atp.typeParams.isEmpty: " + atp.typeParams.isEmpty)
  14 + println(throwsAnn)
  15 + }
  16 + println
  17 +
  18 + {
  19 + val method = clazz.info.member(newTermName("bar"))
  20 + val throwsAnn = method.annotations.head
  21 + val Literal(const) = throwsAnn.args.head
  22 + val tp = const.typeValue
  23 + println("bar")
  24 + println("tp.typeParams.isEmpty: " + tp.typeParams.isEmpty)
  25 + println(throwsAnn)
  26 + }
  27 +}
  28 +"""
  29 +}
6 test/files/jvm/throws-annot-from-java/ThrowsDeclaration_2.java
... ... @@ -0,0 +1,6 @@
  1 +package test;
  2 +
  3 +public class ThrowsDeclaration_2 {
  4 + public void foo() throws IllegalStateException {};
  5 + public void bar() throws PolymorphicException {};
  6 +}

0 comments on commit e22d801

Please sign in to comment.
Something went wrong with that request. Please try again.