diff options
author | Lukas Rytz <lukas.rytz@typesafe.com> | 2015-10-27 09:03:15 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@typesafe.com> | 2015-10-27 09:03:15 +0100 |
commit | 4321ea458ad1258f273ee22a4c6a7606ab054501 (patch) | |
tree | fe68843b632bda3eed3066a83f66b5249dbb86dd /test | |
parent | b194a4e7230334e441cd31b617fdce8e329dfa3a (diff) | |
parent | 4a5a800d4606d917289dc14c35f2035e83f58953 (diff) | |
download | scala-4321ea458ad1258f273ee22a4c6a7606ab054501.tar.gz scala-4321ea458ad1258f273ee22a4c6a7606ab054501.tar.bz2 scala-4321ea458ad1258f273ee22a4c6a7606ab054501.zip |
Merge pull request #4820 from lrytz/t9535
SI-9535 correct bytecode and generic signatures for @throws[TypeParam]
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t9535.check | 7 | ||||
-rw-r--r-- | test/files/neg/t9535.scala | 7 | ||||
-rw-r--r-- | test/files/run/t9535.scala | 22 |
3 files changed, 36 insertions, 0 deletions
diff --git a/test/files/neg/t9535.check b/test/files/neg/t9535.check new file mode 100644 index 0000000000..5c3e3ea8e6 --- /dev/null +++ b/test/files/neg/t9535.check @@ -0,0 +1,7 @@ +t9535.scala:4: error: not found: type E1 + @throws[E1] def f[E1 <: Exception] = 1 + ^ +t9535.scala:6: error: class type required but E found + @throws(classOf[E]) def g: E = ??? // neg test: classOf requires class type + ^ +two errors found diff --git a/test/files/neg/t9535.scala b/test/files/neg/t9535.scala new file mode 100644 index 0000000000..37253804ce --- /dev/null +++ b/test/files/neg/t9535.scala @@ -0,0 +1,7 @@ +class C[E <: Exception] { + // cannot be expressed in Scala (it's allowed in Java) + // https://issues.scala-lang.org/browse/SI-7066 + @throws[E1] def f[E1 <: Exception] = 1 + + @throws(classOf[E]) def g: E = ??? // neg test: classOf requires class type +} diff --git a/test/files/run/t9535.scala b/test/files/run/t9535.scala new file mode 100644 index 0000000000..62e156e456 --- /dev/null +++ b/test/files/run/t9535.scala @@ -0,0 +1,22 @@ +class C[E <: Exception] { + @throws[E] def f = 1 + + @throws(classOf[Exception]) def g: E = ??? + + @throws[E] @throws[Exception] def h = 1 +} + +object Test extends App { + val c = classOf[C[_]] + def sig(method: String) = c.getDeclaredMethod(method).toString + def genSig(method: String) = c.getDeclaredMethod(method).toGenericString + + assert(sig("f") == "public int C.f() throws java.lang.Exception") + assert(genSig("f") == "public int C.f() throws E") + + assert(sig("g") == "public java.lang.Exception C.g() throws java.lang.Exception") + assert(genSig("g") == "public E C.g() throws java.lang.Exception") + + assert(sig("h") == "public int C.h() throws java.lang.Exception,java.lang.Exception") + assert(genSig("h") == "public int C.h() throws E,java.lang.Exception") +} |