Skip to content

Commit 78408e5

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 341e889 commit 78408e5

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-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/StdNames.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ object StdNames {
197197
final val Nothing: N = "Nothing"
198198
final val Null: N = "Null"
199199
final val Object: N = "Object"
200+
final val Product: N = "Product"
200201
final val PartialFunction: N = "PartialFunction"
201202
final val PrefixType: N = "PrefixType"
202203
final val S: N = "S"

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 tpnme.Serializable) || (name eq tpnme.Product)))
476+
denot.setFlag(NoInits)
477+
470478
denot.info = completer
471479
denot.symbol
472480
}

0 commit comments

Comments
 (0)