Skip to content

Commit

Permalink
Load but not enter case accessors fields in Scala2Unpickler (#19926)
Browse files Browse the repository at this point in the history
Fixes #19421
  • Loading branch information
sjrd authored Mar 13, 2024
2 parents cc3c5d5 + 7798862 commit 3901279
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,6 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
// Scala 2 sometimes pickle the same type parameter symbol multiple times
// (see i11173 for an example), but we should only unpickle it once.
|| tag == TYPEsym && flags.is(TypeParam) && symScope(owner).lookup(name.asTypeName).exists
// We discard the private val representing a case accessor. We only load the case accessor def.
|| flags.isAllOf(CaseAccessor| PrivateLocal, butNot = Method)
then
// skip this member
return NoSymbol
Expand Down Expand Up @@ -534,7 +532,10 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
// parameter unpickling and try to emulate it.
!completer.areParamsInitialized
case _ =>
true)
true) &&
// We discard the private val representing a case accessor. We only enter the case accessor def.
// We do need to load these symbols to read properly unpickle the annotations on the symbol (see sbt-test/scala2-compat/i19421).
!flags.isAllOf(CaseAccessor | PrivateLocal, butNot = Method)

if (canEnter)
owner.asClass.enter(sym, symScope(owner))
Expand Down
8 changes: 8 additions & 0 deletions sbt-test/scala2-compat/i19421/S3SnapshotStoreSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import com.typesafe.config.Config
import akka.persistence.snapshot.SnapshotStoreSpec

object ConfigHelper {
def config(): Config = ???
}

class S3SnapshotStoreSpec extends SnapshotStoreSpec(null)
5 changes: 5 additions & 0 deletions sbt-test/scala2-compat/i19421/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scalaVersion := sys.props("plugin.scalaVersion")

libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-persistence-tck" % "2.8.0"
).map(_.cross(CrossVersion.for3Use2_13))
3 changes: 3 additions & 0 deletions sbt-test/scala2-compat/i19421/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> compile
> clean
> compile

0 comments on commit 3901279

Please sign in to comment.