Skip to content

Commit 7798862

Browse files
committed
Load but not enter case accessors fields in Scala2Unpickler
Fixes #19421
1 parent 3694d95 commit 7798862

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,6 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
445445
// Scala 2 sometimes pickle the same type parameter symbol multiple times
446446
// (see i11173 for an example), but we should only unpickle it once.
447447
|| tag == TYPEsym && flags.is(TypeParam) && symScope(owner).lookup(name.asTypeName).exists
448-
// We discard the private val representing a case accessor. We only load the case accessor def.
449-
|| flags.isAllOf(CaseAccessor| PrivateLocal, butNot = Method)
450448
then
451449
// skip this member
452450
return NoSymbol
@@ -534,7 +532,10 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
534532
// parameter unpickling and try to emulate it.
535533
!completer.areParamsInitialized
536534
case _ =>
537-
true)
535+
true) &&
536+
// We discard the private val representing a case accessor. We only enter the case accessor def.
537+
// We do need to load these symbols to read properly unpickle the annotations on the symbol (see sbt-test/scala2-compat/i19421).
538+
!flags.isAllOf(CaseAccessor | PrivateLocal, butNot = Method)
538539

539540
if (canEnter)
540541
owner.asClass.enter(sym, symScope(owner))
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import com.typesafe.config.Config
2+
import akka.persistence.snapshot.SnapshotStoreSpec
3+
4+
object ConfigHelper {
5+
def config(): Config = ???
6+
}
7+
8+
class S3SnapshotStoreSpec extends SnapshotStoreSpec(null)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
scalaVersion := sys.props("plugin.scalaVersion")
2+
3+
libraryDependencies ++= Seq(
4+
"com.typesafe.akka" %% "akka-persistence-tck" % "2.8.0"
5+
).map(_.cross(CrossVersion.for3Use2_13))

sbt-test/scala2-compat/i19421/test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
> compile
2+
> clean
3+
> compile

0 commit comments

Comments
 (0)