Skip to content

Load but not enter case accessors fields in Scala2Unpickler #19926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading