Skip to content

Commit

Permalink
AvoidInfix: make sure to wrap Term.Match as well
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Nov 20, 2024
1 parent 695526e commit 0d14bdd
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class AvoidInfix(implicit ctx: RewriteCtx) extends RewriteSession {

val shouldWrapLhs = !lhsIsWrapped &&
(lhs match {
case _: Term.ApplyInfix => !lhsIsOK
case _: Term.ApplyInfix | _: Term.Match => !lhsIsOK
// foo _ compose bar => (foo _).compose(bar)
// new Foo compose bar => (new Foo).compose(bar)
case _: Term.Eta | _: Term.New => true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7585,18 +7585,10 @@ object a {
} d e
}
>>>
test does not parse
[dialect scala3] `;` expected but `.` found
a .b( c) match {
case _ =>
} .d( e)
^
}
====== full result: ======
object a {
a .b( c) match {
(a.b(c) match {
case _ =>
} .d( e)
}).d(e)
}
<<< AvoidInfix with match, with dot
rewrite.rules = [AvoidInfix]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7296,18 +7296,8 @@ object a {
} d e
}
>>>
test does not parse
[dialect scala3] `;` expected but `.` found
a .b( c) match {
case _ =>
} .d( e)
^
}
====== full result: ======
object a {
a .b( c) match {
case _ =>
} .d( e)
(a.b(c) match { case _ => }).d(e)
}
<<< AvoidInfix with match, with dot
rewrite.rules = [AvoidInfix]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7613,18 +7613,10 @@ object a {
} d e
}
>>>
test does not parse
[dialect scala3] `;` expected but `.` found
a .b( c) match {
case _ =>
} .d( e)
^
}
====== full result: ======
object a {
a .b( c) match {
(a.b(c) match {
case _ =>
} .d( e)
}).d(e)
}
<<< AvoidInfix with match, with dot
rewrite.rules = [AvoidInfix]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7900,18 +7900,12 @@ object a {
} d e
}
>>>
test does not parse
[dialect scala3] `;` expected but `.` found
a .b( c) match {
case _ =>
} .d( e)
^
}
====== full result: ======
object a {
a .b( c) match {
case _ =>
} .d( e)
(
a.b(c) match {
case _ =>
}
).d(e)
}
<<< AvoidInfix with match, with dot
rewrite.rules = [AvoidInfix]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class FormatTests extends FunSuite with CanRunTests with FormatAssertions {
val explored = Debug.explored.get()
logger.debug(s"Total explored: $explored")
if (!onlyUnit && !onlyManual)
assertEquals(explored, 1083242, "total explored")
assertEquals(explored, 1083470, "total explored")
val results = debugResults.result()
// TODO(olafur) don't block printing out test results.
// I don't want to deal with scalaz's Tasks :'(
Expand Down

0 comments on commit 0d14bdd

Please sign in to comment.