Skip to content

Commit 3ebf22e

Browse files
authored
Merge pull request #11858 from dotty-staging/fix-9276-alt
Only pickle StableRealizable flag for methods
2 parents e7d7859 + 456e7c6 commit 3ebf22e

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ object Flags {
300300
*
301301
* - the purity analysis used by the inliner to decide whether it is safe to elide, and
302302
* - the TASTy reader of Scala 2.13, to determine whether there is a $init$ method.
303+
*
304+
* StableRealizable is
305+
* - asserted for methods
306+
* - automatic in conjunction with Module or Enum vals
307+
* - cached for other vals
303308
*/
304309
val (_, StableRealizable @ _, _) = newFlags(24, "<stable>")
305310

@@ -584,6 +589,7 @@ object Flags {
584589
val MethodOrModule: FlagSet = Method | Module
585590
val ParamForwarder: FlagSet = Method | ParamAccessor | StableRealizable // A parameter forwarder
586591
val PrivateMethod: FlagSet = Method | Private
592+
val StableMethod: FlagSet = Method | StableRealizable
587593
val NoInitsInterface: FlagSet = NoInits | PureInterface
588594
val NoInitsTrait: FlagSet = NoInits | Trait // A trait that does not need to be initialized
589595
val ValidForeverFlags: FlagSet = Package | Permanent | Scala2SpecialFlags

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ class TreePickler(pickler: TastyPickler) {
740740
if (flags.is(Accessor)) writeModTag(FIELDaccessor)
741741
if (flags.is(CaseAccessor)) writeModTag(CASEaccessor)
742742
if (flags.is(HasDefault)) writeModTag(HASDEFAULT)
743-
if (flags.is(StableRealizable)) writeModTag(STABLE)
743+
if flags.isAllOf(StableMethod) then writeModTag(STABLE) // other StableRealizable flag occurrences are either implied or can be recomputed
744744
if (flags.is(Extension)) writeModTag(EXTENSION)
745745
if (flags.is(ParamAccessor)) writeModTag(PARAMsetter)
746746
if (flags.is(SuperParamAlias)) writeModTag(PARAMalias)

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,9 @@ class TreeUnpickler(reader: TastyReader,
487487
if (lacksDefinition && tag != PARAM) flags |= Deferred
488488
if (tag == DEFDEF) flags |= Method
489489
if (givenFlags.is(Module))
490-
flags = flags | (if (tag == VALDEF) ModuleValCreationFlags else ModuleClassCreationFlags)
490+
flags |= (if (tag == VALDEF) ModuleValCreationFlags else ModuleClassCreationFlags)
491+
if flags.is(Enum, butNot = Method) && name.isTermName then
492+
flags |= StableRealizable
491493
if (ctx.owner.isClass) {
492494
if (tag == TYPEPARAM) flags |= Param
493495
else if (tag == PARAM) {

0 commit comments

Comments
 (0)