diff options
author | Martin Odersky <odersky@gmail.com> | 2015-03-05 13:22:00 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-03-18 11:14:15 +0100 |
commit | 321563940dee1716c19600efd57acb9ed83a7687 (patch) | |
tree | 9053dfcff007d16ceb6dbaa7256889455a7a07a7 /src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala | |
parent | 7fd242f2f1b1d2f536e73ec0fdb92a34b27b2a89 (diff) | |
download | dotty-321563940dee1716c19600efd57acb9ed83a7687.tar.gz dotty-321563940dee1716c19600efd57acb9ed83a7687.tar.bz2 dotty-321563940dee1716c19600efd57acb9ed83a7687.zip |
Compute PureInterface flag after pickling.
ElimLocals becomes a slightly less trivial transform: NormalizeFlags.
It also computes PureInterface flag, thus relieving Namer and Unpickler
from doing the same in two different ways. Besides, the computation in
Namer/TreeInfo was flawed because it did not take into account that
nested non-static classes are not allowed in an interface (only static
classes are, but these would not be members of the interface in the Scala
sense).
Diffstat (limited to 'src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala b/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala index 4890e14ef..7b2a8fdc4 100644 --- a/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala +++ b/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala @@ -286,9 +286,9 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, roots: Set[ } /** Create symbol of definition node and enter in symAtAddr map - * @return flag set over PureInterface | NoInits according to form of definition + * @return true iff the definition does not contain initialization code */ - def createSymbol()(implicit ctx: Context): FlagSet = { + def createSymbol()(implicit ctx: Context): Boolean = { val start = currentAddr val tag = readByte() val end = readEnd() @@ -340,11 +340,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, roots: Set[ completer.withDecls(newScope) forkAt(templateStart).indexTemplateParams()(localContext(sym)) } - - var resultFlags: FlagSet = EmptyFlags - if (tag != VALDEF || rhsIsEmpty) resultFlags |= NoInits - if (tag != VALDEF && tag != DEFDEF || rhsIsEmpty) resultFlags |= PureInterface - resultFlags + tag != VALDEF || rhsIsEmpty } /** Read modifier list into triplet of flags, annotations and a privateWithin @@ -409,18 +405,18 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, roots: Set[ /** Create symbols for a definitions in statement sequence between * current address and `end`. - * @return flag set over PureInterface | NoInits according to forms of statements + * @return true iff none of the statements contains initialization code */ - def indexStats(end: Addr)(implicit ctx: Context): FlagSet = { - val statFlags = + def indexStats(end: Addr)(implicit ctx: Context): Boolean = { + val noInitss = until(end) { nextByte match { case VALDEF | DEFDEF | TYPEDEF | TYPEPARAM | PARAM => createSymbol() - case EMPTYTREE | IMPORT => skipTree(); PureInterface | NoInits - case _ => skipTree(); EmptyFlags + case EMPTYTREE | IMPORT => skipTree(); true + case _ => skipTree(); false } } - ((PureInterface | NoInits) /: statFlags) (_ & _) + noInitss.forall(_ == true) } /** Create symbols the longest consecutive sequence of parameters with given @@ -506,7 +502,6 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, roots: Set[ setClsInfo( ctx.normalizeToClassRefs(impl.parents.map(_.tpe), cls, cls.unforcedDecls), if (impl.self.isEmpty) NoType else impl.self.tpt.tpe) - if (!cls.is(Trait)) cls.resetFlag(PureInterface) ta.assignType(untpd.TypeDef(sym.name.asTypeName, impl), sym) } else { @@ -549,8 +544,8 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, roots: Set[ untpd.ValDef(readName(), readTpt(), EmptyTree).withType(NoType) } else EmptyValDef - val additionalFlags = fork.indexStats(end) // PureInterface or NoInits - cls.setFlag(additionalFlags) // PureInterface will be reset later if cls is not a trait + val noInits = fork.indexStats(end) + if (noInits) cls.setFlag(NoInits) val constr = readIndexedDef().asInstanceOf[DefDef] def mergeTypeParamsAndAliases(tparams: List[TypeDef], stats: List[Tree]): (List[Tree], List[Tree]) = |