Skip to content

Commit 517aafc

Browse files
committed
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.
1 parent 41ff7c2 commit 517aafc

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
7070
type Bind = tpd.Bind
7171
type New = tpd.New
7272
type Super = tpd.Super
73-
type Modifiers = tpd.Modifiers
73+
type Modifiers = Null
7474
type Annotation = Annotations.Annotation
7575
type ArrayValue = tpd.JavaSeqLiteral
7676
type ApplyDynamic = Null
@@ -944,7 +944,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
944944
}
945945

946946
object ValDef extends ValDefDeconstructor {
947-
def _1: Modifiers = tpd.Modifiers(field.symbol)
947+
def _1: Modifiers = null
948948
def _2: Name = field.name
949949
def _3: Tree = field.tpt
950950
def _4: Tree = field.rhs
@@ -1055,7 +1055,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
10551055
}
10561056

10571057
object DefDef extends DefDefDeconstructor {
1058-
def _1: Modifiers = tpd.Modifiers(field.symbol)
1058+
def _1: Modifiers = null
10591059
def _2: Name = field.name
10601060
def _3: List[TypeDef] = field.tparams
10611061
def _4: List[List[ValDef]] = field.vparamss
@@ -1081,7 +1081,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
10811081
}
10821082

10831083
object ClassDef extends ClassDefDeconstructor {
1084-
def _1: Modifiers = tpd.Modifiers(field.symbol)
1084+
def _1: Modifiers = null
10851085
def _2: Name = field.name
10861086
def _4: Template = field.rhs.asInstanceOf[Template]
10871087
def _3: List[TypeDef] = Nil

src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
1919

2020
private def ta(implicit ctx: Context) = ctx.typeAssigner
2121

22-
def Modifiers(sym: Symbol)(implicit ctx: Context): Modifiers = Modifiers(
23-
sym.flags & (if (sym.isType) ModifierFlags | VarianceFlags else ModifierFlags),
24-
if (sym.privateWithin.exists) sym.privateWithin.asType.name else tpnme.EMPTY,
25-
sym.annotations map (_.tree))
26-
2722
def Ident(tp: NamedType)(implicit ctx: Context): Ident =
2823
ta.assignType(untpd.Ident(tp.name), tp)
2924

src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,14 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
163163
/** Print modifiers from symbols if tree has type, overriding the untpd behavior. */
164164
implicit def modsDeco(mdef: untpd.MemberDef)(implicit ctx: Context): untpd.ModsDecorator =
165165
new untpd.ModsDecorator {
166-
def mods = if (mdef.hasType) tpd.Modifiers(mdef.symbol) else mdef.rawMods
166+
def mods = if (mdef.hasType) Modifiers(mdef.symbol) else mdef.rawMods
167167
}
168168

169+
def Modifiers(sym: Symbol)(implicit ctx: Context): Modifiers = untpd.Modifiers(
170+
sym.flags & (if (sym.isType) ModifierFlags | VarianceFlags else ModifierFlags),
171+
if (sym.privateWithin.exists) sym.privateWithin.asType.name else tpnme.EMPTY,
172+
sym.annotations map (_.tree))
173+
169174
def isLocalThis(tree: Tree) = tree.typeOpt match {
170175
case tp: ThisType => tp.cls == ctx.owner.enclosingClass
171176
case _ => false

0 commit comments

Comments
 (0)