diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-28 09:33:32 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-09-28 09:33:32 +0200 |
commit | 992c72ee5f2f105d587de20efd3858824fc7e7c8 (patch) | |
tree | 8e62d279d4e9ae61849256fe0b06d0f2bd0abb12 /src/dotty/tools/dotc/ast/untpd.scala | |
parent | 517aafc8e42f7204debdd2d9bff30c9fb90fab98 (diff) | |
download | dotty-992c72ee5f2f105d587de20efd3858824fc7e7c8.tar.gz dotty-992c72ee5f2f105d587de20efd3858824fc7e7c8.tar.bz2 dotty-992c72ee5f2f105d587de20efd3858824fc7e7c8.zip |
Make Modifiers untyped only.
The typed variant is no longer needed. This means modifiers can safely be
ignored in typed trees if we so choose.
Diffstat (limited to 'src/dotty/tools/dotc/ast/untpd.scala')
-rw-r--r-- | src/dotty/tools/dotc/ast/untpd.scala | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/ast/untpd.scala b/src/dotty/tools/dotc/ast/untpd.scala index 102ee2e4e..61c3a79a4 100644 --- a/src/dotty/tools/dotc/ast/untpd.scala +++ b/src/dotty/tools/dotc/ast/untpd.scala @@ -86,6 +86,52 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { */ class InfixOpBlock(leftOperand: Tree, rightOp: Tree) extends Block(leftOperand :: Nil, rightOp) + // ----- Modifiers ----------------------------------------------------- + + /** Modifiers and annotations for definitions + * @param flags The set flags + * @param privateWithin If a private or protected has is followed by a + * qualifier [q], the name q, "" as a typename otherwise. + * @param annotations The annotations preceding the modifiers + */ + case class Modifiers ( + flags: FlagSet = EmptyFlags, + privateWithin: TypeName = tpnme.EMPTY, + annotations: List[Tree] = Nil) extends Positioned with Cloneable { + + def is(fs: FlagSet): Boolean = flags is fs + def is(fc: FlagConjunction): Boolean = flags is fc + + def | (fs: FlagSet): Modifiers = withFlags(flags | fs) + def & (fs: FlagSet): Modifiers = withFlags(flags & fs) + def &~(fs: FlagSet): Modifiers = withFlags(flags &~ fs) + + def toTypeFlags: Modifiers = withFlags(flags.toTypeFlags) + def toTermFlags: Modifiers = withFlags(flags.toTermFlags) + + def withFlags(flags: FlagSet) = + if (this.flags == flags) this + else copy(flags = flags) + + def withAddedAnnotation(annot: Tree): Modifiers = + if (annotations.exists(_ eq annot)) this + else withAnnotations(annotations :+ annot) + + def withAnnotations(annots: List[Tree]): Modifiers = + if (annots eq annotations) this + else copy(annotations = annots) + + def withPrivateWithin(pw: TypeName) = + if (pw.isEmpty) this + else copy(privateWithin = pw) + + def hasFlags = flags != EmptyFlags + def hasAnnotations = annotations.nonEmpty + def hasPrivateWithin = privateWithin != tpnme.EMPTY + } + + @sharable val EmptyModifiers: Modifiers = new Modifiers() + // ----- TypeTrees that refer to other tree's symbols ------------------- /** A type tree that gets its type from some other tree's symbol. Enters the |