Skip to content

Commit 4c2c4c1

Browse files
committed
SI-8576 Minimal changes for -Xcheckinit compatibility
As explained in https://issues.scala-lang.org/browse/SI-8576, I expect serialization compatibility between builds with and without `-Xcheckinit` to be unattainable. This commit contains some minor fixes for issues discovered while running builds with `-Xcheckinit`: - Add `@SerialVersionUID` to `scala.collection.immutable.Vector`, as requested in SI-8576. Note that this does not make `Vector` serialization compatible. - Use lazy initialization for `global` in `PresentationCompilation`. It used to access the uninitialized `self` variable (which seems to be inconsequential in practice and only fails under `-Xcheckinit`). We should consider using `Externalizable` instead of `Serializable` for collections in 2.13 to make collection classes serialization compatible.
1 parent 1e7ce6e commit 4c2c4c1

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/library/scala/collection/immutable/Vector.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ object Vector extends IndexedSeqFactory[Vector] {
5959
* @define mayNotTerminateInf
6060
* @define willNotTerminateInf
6161
*/
62+
@SerialVersionUID(-1334388273712300479L)
6263
final class Vector[+A] private[immutable] (private[collection] val startIndex: Int, private[collection] val endIndex: Int, focus: Int)
6364
extends AbstractSeq[A]
6465
with IndexedSeq[A]

src/repl/scala/tools/nsc/interpreter/PresentationCompilation.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ trait PresentationCompilation {
6969
val interactiveGlobal = new interactive.Global(copySettings, storeReporter) { self =>
7070
override lazy val platform: ThisPlatform = {
7171
new JavaPlatform {
72-
val global: self.type = self
72+
lazy val global: self.type = self
7373
override private[nsc] lazy val classPath: ClassPath = mergedFlatClasspath
7474
}
7575
}

0 commit comments

Comments
 (0)