diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-26 13:46:26 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-09-26 13:46:26 +0200 |
commit | 517aafc8e42f7204debdd2d9bff30c9fb90fab98 (patch) | |
tree | 063b9e8dbfb819614414aaf20ae3e2a1fa14c10e | |
parent | 41ff7c286525855e345fc0641481a7cd9ec2ccee (diff) | |
download | dotty-517aafc8e42f7204debdd2d9bff30c9fb90fab98.tar.gz dotty-517aafc8e42f7204debdd2d9bff30c9fb90fab98.tar.bz2 dotty-517aafc8e42f7204debdd2d9bff30c9fb90fab98.zip |
Eliminate tpd.Modifiers.
Backend does not need them after all, can just use nulls there.
So the functionality is only used for printing, and it makes
sense to move everything there.
-rw-r--r-- | src/dotty/tools/backend/jvm/DottyBackendInterface.scala | 8 | ||||
-rw-r--r-- | src/dotty/tools/dotc/ast/tpd.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/printing/RefinedPrinter.scala | 7 |
3 files changed, 10 insertions, 10 deletions
diff --git a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala index c70cb4be2..2d60d851c 100644 --- a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala +++ b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala @@ -70,7 +70,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma type Bind = tpd.Bind type New = tpd.New type Super = tpd.Super - type Modifiers = tpd.Modifiers + type Modifiers = Null type Annotation = Annotations.Annotation type ArrayValue = tpd.JavaSeqLiteral type ApplyDynamic = Null @@ -944,7 +944,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma } object ValDef extends ValDefDeconstructor { - def _1: Modifiers = tpd.Modifiers(field.symbol) + def _1: Modifiers = null def _2: Name = field.name def _3: Tree = field.tpt def _4: Tree = field.rhs @@ -1055,7 +1055,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma } object DefDef extends DefDefDeconstructor { - def _1: Modifiers = tpd.Modifiers(field.symbol) + def _1: Modifiers = null def _2: Name = field.name def _3: List[TypeDef] = field.tparams def _4: List[List[ValDef]] = field.vparamss @@ -1081,7 +1081,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma } object ClassDef extends ClassDefDeconstructor { - def _1: Modifiers = tpd.Modifiers(field.symbol) + def _1: Modifiers = null def _2: Name = field.name def _4: Template = field.rhs.asInstanceOf[Template] def _3: List[TypeDef] = Nil diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala index 355843cad..f59bb7a47 100644 --- a/src/dotty/tools/dotc/ast/tpd.scala +++ b/src/dotty/tools/dotc/ast/tpd.scala @@ -19,11 +19,6 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { private def ta(implicit ctx: Context) = ctx.typeAssigner - def Modifiers(sym: Symbol)(implicit ctx: Context): Modifiers = Modifiers( - sym.flags & (if (sym.isType) ModifierFlags | VarianceFlags else ModifierFlags), - if (sym.privateWithin.exists) sym.privateWithin.asType.name else tpnme.EMPTY, - sym.annotations map (_.tree)) - def Ident(tp: NamedType)(implicit ctx: Context): Ident = ta.assignType(untpd.Ident(tp.name), tp) diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 8b91d1a7a..205d2b6b9 100644 --- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -163,9 +163,14 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { /** Print modifiers from symbols if tree has type, overriding the untpd behavior. */ implicit def modsDeco(mdef: untpd.MemberDef)(implicit ctx: Context): untpd.ModsDecorator = new untpd.ModsDecorator { - def mods = if (mdef.hasType) tpd.Modifiers(mdef.symbol) else mdef.rawMods + def mods = if (mdef.hasType) Modifiers(mdef.symbol) else mdef.rawMods } + def Modifiers(sym: Symbol)(implicit ctx: Context): Modifiers = untpd.Modifiers( + sym.flags & (if (sym.isType) ModifierFlags | VarianceFlags else ModifierFlags), + if (sym.privateWithin.exists) sym.privateWithin.asType.name else tpnme.EMPTY, + sym.annotations map (_.tree)) + def isLocalThis(tree: Tree) = tree.typeOpt match { case tp: ThisType => tp.cls == ctx.owner.enclosingClass case _ => false |