Skip to content

Commit

Permalink
Merge pull request #1213 from olafurpg/1203
Browse files Browse the repository at this point in the history
Avoid lookup up match for non-Token.Left{Brace,Paren}
  • Loading branch information
olafurpg authored Jun 5, 2018
2 parents 871555f + ffd617c commit 7dd4b00
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -751,10 +751,19 @@ class FormatOps(val tree: Tree, val initStyle: ScalafmtConfig) {
leftTok2tok(matching(token)) match {
case FormatToken(RightParenOrBracket(), l @ LeftParen(), _) =>
loop(l)
// This case only applies to classes
case f @ FormatToken(RightBracket(), mod, _) if mod.is[Modifier] =>
loop(next(f).right)
case FormatToken(r @ RightParenOrBracket(), _, _) => Some(r)
case f @ FormatToken(left @ RightParenOrBracket(), right, _) =>
right match {
case Modifier() =>
// This case only applies to classes
next(f).right match {
case x @ (_: Token.LeftParen | _: Token.LeftBracket) =>
loop(x)
case _ =>
Some(left)
}
case _ =>
Some(left)
}
case _ => None
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,13 @@ class SomeVeryLongName[
SomeOtherTypeName,
YetAnotherType]
extends Something
<<< #1203
object Recorder {
sealed abstract class Ast[A]
final case class Record()
}
>>>
object Recorder {
sealed abstract class Ast[A]
final case class Record()
}

0 comments on commit 7dd4b00

Please sign in to comment.