Skip to content

Commit

Permalink
FormatWriter: do not rewrite {} => () around Defn
Browse files Browse the repository at this point in the history
Fixes #1756.
  • Loading branch information
kitbellew committed Mar 1, 2020
1 parent 7d0c56d commit c7e5e6f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ object RedundantBraces extends Rewrite {
def canRewriteWithParens(f: Term.Function, nested: Boolean = false): Boolean =
!needParensAroundParams(f) && (getTermSingleStat(f.body) match {
case Some(t: Term.Function) => canRewriteWithParens(t, true)
case Some(_: Defn) => false
case x => nested || x.isDefined
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,8 @@ object a {
}
}
>>>
test does not parse
object a {
childContext.onDone(_ => val _ = self.withChildren(_.remove(childContext)))
childContext.onDone { _ => val _ = self.withChildren(_.remove(childContext)) }
}
<<< #1756 def
object a {
Expand All @@ -203,9 +202,8 @@ object a {
}
}
>>>
test does not parse
object a {
childContext.onDone(_ => def a = self.withChildren(_.remove(childContext)))
childContext.onDone { _ => def a = self.withChildren(_.remove(childContext)) }
}
<<< #1756 type
object a {
Expand All @@ -214,7 +212,6 @@ object a {
}
}
>>>
test does not parse
object a {
childContext.onDone(_ => type a = Int)
childContext.onDone { _ => type a = Int }
}

0 comments on commit c7e5e6f

Please sign in to comment.