diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2015-10-26 15:47:54 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2015-10-26 17:16:07 +0100 |
commit | 4a5a800d4606d917289dc14c35f2035e83f58953 (patch) | |
tree | 1ed0ae3e948fc6de0f3bd451ae85e5dbdaacc7d5 /test/files/run/t9535.scala | |
parent | 462dc9af886391c9c31cb6949b15e69b0cab55ef (diff) | |
download | scala-4a5a800d4606d917289dc14c35f2035e83f58953.tar.gz scala-4a5a800d4606d917289dc14c35f2035e83f58953.tar.bz2 scala-4a5a800d4606d917289dc14c35f2035e83f58953.zip |
SI-9535 correct bytecode and generic signatures for @throws[TypeParam]
For @throws[E] where E is not a class type, GenASM incorrectly writes
the non-class type to the classfile. GenBCode used to crash before
this commit. Now GenBCode correctly emits the erased type (like
javac) and adds a generic signature.
Diffstat (limited to 'test/files/run/t9535.scala')
-rw-r--r-- | test/files/run/t9535.scala | 22 |
1 files changed, 22 insertions, 0 deletions
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") +} |