Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TreeOps: remove last internal.Impl.unapply use #3427

Merged
merged 1 commit into from
Dec 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ object TreeOps {
def addFT(ft: FormatToken, tree: Tree): Unit = ret += hash(ft.left) -> tree
def addTok(token: Token, tree: Tree) = addFT(ftoks.after(token), tree)
def addTree(t: Tree, o: Tree) = ftoks.getHeadOpt(t).foreach(addFT(_, o))
def addAll(trees: Seq[Tree]) = trees.foreach(x => addTree(x, x))
def addOne(t: Tree) = addTree(t, t)
def addAll(trees: Seq[Tree]) = trees.foreach(addOne)

def addDefnTokens(
mods: Seq[Mod],
Expand Down Expand Up @@ -162,16 +163,19 @@ object TreeOps {
Some(true)
case _ => Some(false)
}
if (parentApply.isDefined) addAll(Seq(arg))
if (parentApply.isDefined) addOne(arg)
}
// special handling for rewritten apply(x => { b }) to a { x => b }
case Term.Apply.internal
.Impl(_, ac @ Term.ArgClause((f: Term.Function) :: Nil, _))
if ac.tokens.lastOption.exists { x =>
x.is[Token.RightParen] && // see if closing paren is now brace
ftoks.prevNonComment(ftoks(x)).left.is[Token.RightBrace]
} =>
addAll(Seq(f))
case t: Term.Apply =>
val ac = t.argClause
ac.values match {
case (f: Term.Function) :: Nil if ac.tokens.lastOption.exists { x =>
x.is[Token.RightParen] && // see if closing paren is now brace
ftoks.prevNonComment(ftoks(x)).left.is[Token.RightBrace]
} =>
addOne(f)
case _ =>
}
case t => // Nothing
addAll(extractStatementsIfAny(t))
}
Expand Down