summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2016-12-14 08:35:49 +1000
committerJason Zaugg <jzaugg@gmail.com>2016-12-14 09:34:28 +1000
commit64a0ec47092a1310e746b401837c61cefc591faa (patch)
tree6d36154928da33a7698d0e05432af7d68133e033 /test
parent4c0a9f13e4c2d1669571d76645e180f60307f70f (diff)
downloadscala-64a0ec47092a1310e746b401837c61cefc591faa.tar.gz
scala-64a0ec47092a1310e746b401837c61cefc591faa.tar.bz2
scala-64a0ec47092a1310e746b401837c61cefc591faa.zip
Modules w. serializable type alias "companions" are not serializable
The behaviour changed in #5550, this commit adapts to the change so that we'll be binary compatible after boostrapping. MiMa alerted us to a change in the parentage of two objects in the forkjoin package object. In Scala 2.12.0/1, they implemented `scala.Serializable`. Recently, this (synthetically added) parent was absent. This appears to be due to a bug fix in `companionSymbolOf`, which no longer treats objects and same-named type aliases to be companions. This commit manually adds the formerly-synthetic parents to these objects, and documents the change in compiler behaviour with a test. Fixes scala/scala-dev#290
Diffstat (limited to 'test')
-rw-r--r--test/files/run/SD-290.scala39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/files/run/SD-290.scala b/test/files/run/SD-290.scala
new file mode 100644
index 0000000000..0af9cb7cfa
--- /dev/null
+++ b/test/files/run/SD-290.scala
@@ -0,0 +1,39 @@
+object p1 {
+ class B
+ object B
+
+ class C extends java.io.Serializable
+ object C
+
+ type D = DD
+ object D
+}
+package object p2 {
+ class B
+ object B
+
+ class C extends java.io.Serializable
+ object C
+
+ type D = DD
+ object D
+
+}
+class DD extends java.io.Serializable
+
+object Test {
+ def main(args: Array[String]): Unit = {
+
+ // This is the behaviour that was intended and was unchanged by this commmit.
+ assert(!(p1.B : Object).isInstanceOf[scala.Serializable])
+ assert(p1.C.isInstanceOf[scala.Serializable])
+ assert(!(p1.D: Object).isInstanceOf[scala.Serializable])
+
+ assert(!(p2.B : Object).isInstanceOf[scala.Serializable])
+ assert(p2.C.isInstanceOf[scala.Serializable])
+
+ // this behaviour was different in 2.12.1 and earlier due to a bug
+ // in companionSymbolOf
+ assert(!(p2.D: Object).isInstanceOf[scala.Serializable])
+ }
+}