diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2014-10-10 14:02:12 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2014-10-10 16:10:17 +0200 |
commit | 4e546eb08c191fb7b9ccfd06f9a749bd1326cd64 (patch) | |
tree | 16b302b0a51e1b3bc7d4ef4cfdce6ef8db0852ef | |
parent | 926c0946a72314e5a5c720617c149705c6bb588c (diff) | |
download | scala-4e546eb08c191fb7b9ccfd06f9a749bd1326cd64.tar.gz scala-4e546eb08c191fb7b9ccfd06f9a749bd1326cd64.tar.bz2 scala-4e546eb08c191fb7b9ccfd06f9a749bd1326cd64.zip |
Fix t8549 under -Ydelambdafy:method
the structure of Option.class generated by delambdafy:method is
slightly different. For example, lambdas declared within Option are
not emitted as nested classes, so under delambdafy:method there's no
inner class entry for anonfun classes.
The test failed because serializing a ClassTag involves serializing an
Option. Option did not have a `@SerialVersionUID`, and the classfile
generated by delambdafy:method has a different value.
The annotation is required on the parent class (Option) as well as the
subclasses (Some / None). De-serializing a Some will fail if Option
has a different SerialVersionUID.
Relates to SI-8576. We should probably have more SVUID annotations in
the library.
-rw-r--r-- | src/library/scala/Option.scala | 3 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/List.scala | 4 | ||||
-rw-r--r-- | test/files/run/t8549.scala | 5 |
3 files changed, 10 insertions, 2 deletions
diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala index 66900e7258..b073688a5b 100644 --- a/src/library/scala/Option.scala +++ b/src/library/scala/Option.scala @@ -94,6 +94,7 @@ object Option { * @define bfinfo an implicit value of class `CanBuildFrom` which determines the result class `That` from the current * representation type `Repr` and the new element type `B`. */ +@SerialVersionUID(-114498752079829388L) // value computed by serialver for 2.11.2, annotation added in 2.11.4 sealed abstract class Option[+A] extends Product with Serializable { self => @@ -328,6 +329,7 @@ sealed abstract class Option[+A] extends Product with Serializable { * @author Martin Odersky * @version 1.0, 16/07/2003 */ +@SerialVersionUID(1234815782226070388L) // value computed by serialver for 2.11.2, annotation added in 2.11.4 final case class Some[+A](x: A) extends Option[A] { def isEmpty = false def get = x @@ -339,6 +341,7 @@ final case class Some[+A](x: A) extends Option[A] { * @author Martin Odersky * @version 1.0, 16/07/2003 */ +@SerialVersionUID(5066590221178148012L) // value computed by serialver for 2.11.2, annotation added in 2.11.4 case object None extends Option[Nothing] { def isEmpty = true def get = throw new NoSuchElementException("None.get") diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index aa9dec2761..a709d90798 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -80,6 +80,7 @@ import java.io._ * @define mayNotTerminateInf * @define willNotTerminateInf */ +@SerialVersionUID(-6084104484083858598L) // value computed by serialver for 2.11.2, annotation added in 2.11.4 sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product @@ -428,13 +429,14 @@ case object Nil extends List[Nothing] { } /** A non empty list characterized by a head and a tail. - * @param hd the first element of the list + * @param head the first element of the list * @param tl the list containing the remaining elements of this list after the first one. * @tparam B the type of the list elements. * @author Martin Odersky * @version 1.0, 15/07/2003 * @since 2.8 */ +@SerialVersionUID(509929039250432923L) // value computed by serialver for 2.11.2, annotation added in 2.11.4 final case class ::[B](override val head: B, private[scala] var tl: List[B]) extends List[B] { override def tail : List[B] = tl override def isEmpty: Boolean = false diff --git a/test/files/run/t8549.scala b/test/files/run/t8549.scala index d3355208fa..cb254e3810 100644 --- a/test/files/run/t8549.scala +++ b/test/files/run/t8549.scala @@ -79,9 +79,12 @@ object Test extends App { } } - // Generated on 20140505-14:47:14 with Scala version 2.11.1-20140505-142300-e8562571d2) + // Generated on 20141010-14:01:28 with Scala version 2.11.2) overwrite.foreach(updateComment) + check(Some(1))("rO0ABXNyAApzY2FsYS5Tb21lESLyaV6hi3QCAAFMAAF4dAASTGphdmEvbGFuZy9PYmplY3Q7eHIADHNjYWxhLk9wdGlvbv5pN/3bDmZ0AgAAeHBzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAQ==") + check(None)("rO0ABXNyAAtzY2FsYS5Ob25lJEZQJPZTypSsAgAAeHIADHNjYWxhLk9wdGlvbv5pN/3bDmZ0AgAAeHA=") + check(List(1, 2, 3))( "rO0ABXNyADJzY2FsYS5jb2xsZWN0aW9uLmltbXV0YWJsZS5MaXN0JFNlcmlhbGl6YXRpb25Qcm94eQAAAAAAAAABAwAAeHBzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAXNxAH4AAgAAAAJzcQB+AAIAAAADc3IALHNjYWxhLmNvbGxlY3Rpb24uaW1tdXRhYmxlLkxpc3RTZXJpYWxpemVFbmQkilxjW/dTC20CAAB4cHg=") check(Nil)( "rO0ABXNyADJzY2FsYS5jb2xsZWN0aW9uLmltbXV0YWJsZS5MaXN0JFNlcmlhbGl6YXRpb25Qcm94eQAAAAAAAAABAwAAeHBzcgAsc2NhbGEuY29sbGVjdGlvbi5pbW11dGFibGUuTGlzdFNlcmlhbGl6ZUVuZCSKXGNb91MLbQIAAHhweA==") |