Skip to content

Commit 32a5632

Browse files
committed
fix copy of flags for ModuleDef and refactor code
1 parent 5021c76 commit 32a5632

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -391,80 +391,80 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
391391

392392
def ModuleDef(tree: Tree)(name: TermName, impl: Template) = tree match {
393393
case tree: ModuleDef if (name eq tree.name) && (impl eq tree.impl) => tree
394-
case _ => untpd.ModuleDef(name, impl).withPos(tree.pos)
394+
case _ => finalize(tree, untpd.ModuleDef(name, impl))
395395
}
396396
def ParsedTry(tree: Tree)(expr: Tree, handler: Tree, finalizer: Tree) = tree match {
397397
case tree: ParsedTry
398398
if (expr eq tree.expr) && (handler eq tree.handler) && (finalizer eq tree.finalizer) => tree
399-
case _ => untpd.ParsedTry(expr, handler, finalizer).withPos(tree.pos)
399+
case _ => finalize(tree, untpd.ParsedTry(expr, handler, finalizer))
400400
}
401401
def SymbolLit(tree: Tree)(str: String) = tree match {
402402
case tree: SymbolLit if str == tree.str => tree
403-
case _ => untpd.SymbolLit(str).withPos(tree.pos)
403+
case _ => finalize(tree, untpd.SymbolLit(str))
404404
}
405405
def InterpolatedString(tree: Tree)(id: TermName, segments: List[Tree]) = tree match {
406406
case tree: InterpolatedString if (id eq tree.id) && (segments eq tree.segments) => tree
407-
case _ => untpd.InterpolatedString(id, segments).withPos(tree.pos)
407+
case _ => finalize(tree, untpd.InterpolatedString(id, segments))
408408
}
409409
def Function(tree: Tree)(args: List[Tree], body: Tree) = tree match {
410410
case tree: Function if (args eq tree.args) && (body eq tree.body) => tree
411-
case _ => untpd.Function(args, body).withPos(tree.pos)
411+
case _ => finalize(tree, untpd.Function(args, body))
412412
}
413413
def InfixOp(tree: Tree)(left: Tree, op: Ident, right: Tree) = tree match {
414414
case tree: InfixOp if (left eq tree.left) && (op eq tree.op) && (right eq tree.right) => tree
415-
case _ => untpd.InfixOp(left, op, right).withPos(tree.pos)
415+
case _ => finalize(tree, untpd.InfixOp(left, op, right))
416416
}
417417
def PostfixOp(tree: Tree)(od: Tree, op: Ident) = tree match {
418418
case tree: PostfixOp if (od eq tree.od) && (op eq tree.op) => tree
419-
case _ => untpd.PostfixOp(od, op).withPos(tree.pos)
419+
case _ => finalize(tree, untpd.PostfixOp(od, op))
420420
}
421421
def PrefixOp(tree: Tree)(op: Ident, od: Tree) = tree match {
422422
case tree: PrefixOp if (op eq tree.op) && (od eq tree.od) => tree
423-
case _ => untpd.PrefixOp(op, od).withPos(tree.pos)
423+
case _ => finalize(tree, untpd.PrefixOp(op, od))
424424
}
425425
def Parens(tree: Tree)(t: Tree) = tree match {
426426
case tree: Parens if t eq tree.t => tree
427-
case _ => untpd.Parens(t).withPos(tree.pos)
427+
case _ => finalize(tree, untpd.Parens(t))
428428
}
429429
def Tuple(tree: Tree)(trees: List[Tree]) = tree match {
430430
case tree: Tuple if trees eq tree.trees => tree
431-
case _ => untpd.Tuple(trees).withPos(tree.pos)
431+
case _ => finalize(tree, untpd.Tuple(trees))
432432
}
433433
def Throw(tree: Tree)(expr: Tree) = tree match {
434434
case tree: Throw if expr eq tree.expr => tree
435-
case _ => untpd.Throw(expr).withPos(tree.pos)
435+
case _ => finalize(tree, untpd.Throw(expr))
436436
}
437437
def WhileDo(tree: Tree)(cond: Tree, body: Tree) = tree match {
438438
case tree: WhileDo if (cond eq tree.cond) && (body eq tree.body) => tree
439-
case _ => untpd.WhileDo(cond, body).withPos(tree.pos)
439+
case _ => finalize(tree, untpd.WhileDo(cond, body))
440440
}
441441
def DoWhile(tree: Tree)(body: Tree, cond: Tree) = tree match {
442442
case tree: DoWhile if (body eq tree.body) && (cond eq tree.cond) => tree
443-
case _ => untpd.DoWhile(body, cond).withPos(tree.pos)
443+
case _ => finalize(tree, untpd.DoWhile(body, cond))
444444
}
445445
def ForYield(tree: Tree)(enums: List[Tree], expr: Tree) = tree match {
446446
case tree: ForYield if (enums eq tree.enums) && (expr eq tree.expr) => tree
447-
case _ => untpd.ForYield(enums, expr).withPos(tree.pos)
447+
case _ => finalize(tree, untpd.ForYield(enums, expr))
448448
}
449449
def ForDo(tree: Tree)(enums: List[Tree], body: Tree) = tree match {
450450
case tree: ForDo if (enums eq tree.enums) && (body eq tree.body) => tree
451-
case _ => untpd.ForDo(enums, body).withPos(tree.pos)
451+
case _ => finalize(tree, untpd.ForDo(enums, body))
452452
}
453453
def GenFrom(tree: Tree)(pat: Tree, expr: Tree) = tree match {
454454
case tree: GenFrom if (pat eq tree.pat) && (expr eq tree.expr) => tree
455-
case _ => untpd.GenFrom(pat, expr).withPos(tree.pos)
455+
case _ => finalize(tree, untpd.GenFrom(pat, expr))
456456
}
457457
def GenAlias(tree: Tree)(pat: Tree, expr: Tree) = tree match {
458458
case tree: GenAlias if (pat eq tree.pat) && (expr eq tree.expr) => tree
459-
case _ => untpd.GenAlias(pat, expr).withPos(tree.pos)
459+
case _ => finalize(tree, untpd.GenAlias(pat, expr))
460460
}
461461
def ContextBounds(tree: Tree)(bounds: TypeBoundsTree, cxBounds: List[Tree]) = tree match {
462462
case tree: ContextBounds if (bounds eq tree.bounds) && (cxBounds eq tree.cxBounds) => tree
463-
case _ => untpd.ContextBounds(bounds, cxBounds).withPos(tree.pos)
463+
case _ => finalize(tree, untpd.ContextBounds(bounds, cxBounds))
464464
}
465465
def PatDef(tree: Tree)(mods: Modifiers, pats: List[Tree], tpt: Tree, rhs: Tree) = tree match {
466466
case tree: PatDef if (mods eq tree.mods) && (pats eq tree.pats) && (tpt eq tree.tpt) && (rhs eq tree.rhs) => tree
467-
case _ => untpd.PatDef(mods, pats, tpt, rhs).withPos(tree.pos)
467+
case _ => finalize(tree, untpd.PatDef(mods, pats, tpt, rhs))
468468
}
469469
}
470470

0 commit comments

Comments
 (0)