summaryrefslogtreecommitdiff
path: root/test/files/run/t8574.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-05-10 10:49:36 +0200
committerJason Zaugg <jzaugg@gmail.com>2014-05-16 16:02:45 +0200
commitf9abdcef6c9b8d96e1aaf98942938e2e875285d0 (patch)
treefc7605901c830000883f26b941fe13a62ae82230 /test/files/run/t8574.scala
parentd079e769b9372daae8d7770c4156f85ea1af6621 (diff)
downloadscala-f9abdcef6c9b8d96e1aaf98942938e2e875285d0.tar.gz
scala-f9abdcef6c9b8d96e1aaf98942938e2e875285d0.tar.bz2
scala-f9abdcef6c9b8d96e1aaf98942938e2e875285d0.zip
SI-8574 Copy @SerialVersionUID, etc, to specialized subclasses
The test case demonstrates that this is important for serialization and for strictfp. (Although the latter is still pretty broken, see SI-7954.) Now that the synthetic subclass of `Tuple2[Int, Int]` also has the `@deprecatedInheritance` annotation, I had to change the spot that issues this warning to be silent after the typer phase. Otherwise, we get two warnings in `run/t3888.scala`. This also remedies double warnings that were incurred in `neg/t6162-inheritance`.
Diffstat (limited to 'test/files/run/t8574.scala')
-rw-r--r--test/files/run/t8574.scala27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/files/run/t8574.scala b/test/files/run/t8574.scala
new file mode 100644
index 0000000000..8c23ada482
--- /dev/null
+++ b/test/files/run/t8574.scala
@@ -0,0 +1,27 @@
+import annotation._
+
+@SerialVersionUID(42) @strictfp class Foo[@specialized(Int) T] extends Serializable {
+ def foo(t: T) = t
+}
+
+object Test extends App {
+ def checkUID(cls: Class[_], expected: Long) = {
+ val actual = java.io.ObjectStreamClass.lookup(cls).getSerialVersionUID
+ assert(actual == expected, s"$actual != expected for ${cls}")
+ }
+ def checkStrictFp(cls: Class[_]) = {
+ import java.lang.reflect._
+ for (m <- cls.getDeclaredMethods) {
+ val isStrict = Modifier.isStrict(m.getModifiers)
+ assert(isStrict, cls)
+ }
+ }
+ def check(x: AnyRef) {
+ checkUID(x.getClass, 42)
+ checkStrictFp(x.getClass)
+ }
+
+ check(new Foo[String])
+ check(new Foo[Int])
+}
+