Skip to content

Commit ea95606

Browse files
committed
Avoid initializing Product and Serializable too early
This lead to crashes in the full bootstrap and doesn't seem necessary in any case.
1 parent dd320ae commit ea95606

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,13 +1391,6 @@ class Definitions {
13911391
for (m <- ScalaShadowingPackageClass.info.decls)
13921392
ScalaPackageClass.enter(m)
13931393

1394-
// Temporary measure, as long as we do not read these classes from Tasty.
1395-
// Scala-2 classes don't have NoInits set even if they are pure. We override this
1396-
// for Product and Serializable so that case classes can be pure. A full solution
1397-
// requires that we read all Scala code from Tasty.
1398-
ProductClass.setFlag(NoInits)
1399-
SerializableClass.setFlag(NoInits)
1400-
14011394
// force initialization of every symbol that is synthesized or hijacked by the compiler
14021395
val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses()
14031396

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,14 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
467467
def completeRoot(denot: ClassDenotation, completer: LazyType): Symbol = {
468468
denot.setFlag(flags)
469469
denot.resetFlag(Touched) // allow one more completion
470+
471+
// Temporary measure, as long as we do not read these classes from Tasty.
472+
// Scala-2 classes don't have NoInits set even if they are pure. We override this
473+
// for Product and Serializable so that case classes can be pure. A full solution
474+
// requires that we read all Scala code from Tasty.
475+
if (owner == defn.ScalaPackageClass && ((name eq nme.Serializable) || (name eq nme.Product)))
476+
denot.setFlag(NoInits)
477+
470478
denot.info = completer
471479
denot.symbol
472480
}

0 commit comments

Comments
 (0)