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

AvoidInfix: make sure to wrap Term.Match as well #4566

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
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 @@ -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 @@ -7564,3 +7564,42 @@ object Build:
}
}.evaluated
)
<<< AvoidInfix with match
rewrite.rules = [AvoidInfix]
===
object a {
a b c match
case _ =>
}
>>>
object a {
a.b(c) match
case _ =>
}
<<< AvoidInfix with match within applyinfix
rewrite.rules = [AvoidInfix]
===
object a {
a b c match {
case _ =>
} d e
}
>>>
object a {
(a.b(c) match {
case _ =>
}).d(e)
}
<<< AvoidInfix with match, with dot
rewrite.rules = [AvoidInfix]
===
object a {
(a.b(c)).match
case _ =>
}
>>>
object a {
(a.b(c))
.match
case _ =>
}
Original file line number Diff line number Diff line change
Expand Up @@ -7275,3 +7275,39 @@ object Build:
config: GenerationConfig => config.remove[SiteRoot]
}
}.evaluated)
<<< AvoidInfix with match
rewrite.rules = [AvoidInfix]
===
object a {
a b c match
case _ =>
}
>>>
object a {
a.b(c) match
case _ =>
}
<<< AvoidInfix with match within applyinfix
rewrite.rules = [AvoidInfix]
===
object a {
a b c match {
case _ =>
} d e
}
>>>
object a {
(a.b(c) match { case _ => }).d(e)
}
<<< AvoidInfix with match, with dot
rewrite.rules = [AvoidInfix]
===
object a {
(a.b(c)).match
case _ =>
}
>>>
object a {
(a.b(c)).match
case _ =>
}
Original file line number Diff line number Diff line change
Expand Up @@ -7592,3 +7592,41 @@ object Build:
}
}.evaluated
)
<<< AvoidInfix with match
rewrite.rules = [AvoidInfix]
===
object a {
a b c match
case _ =>
}
>>>
object a {
a.b(c) match
case _ =>
}
<<< AvoidInfix with match within applyinfix
rewrite.rules = [AvoidInfix]
===
object a {
a b c match {
case _ =>
} d e
}
>>>
object a {
(a.b(c) match {
case _ =>
}).d(e)
}
<<< AvoidInfix with match, with dot
rewrite.rules = [AvoidInfix]
===
object a {
(a.b(c)).match
case _ =>
}
>>>
object a {
(a.b(c)).match
case _ =>
}
Original file line number Diff line number Diff line change
Expand Up @@ -7879,3 +7879,43 @@ object Build:
}
.evaluated
)
<<< AvoidInfix with match
rewrite.rules = [AvoidInfix]
===
object a {
a b c match
case _ =>
}
>>>
object a {
a.b(c) match
case _ =>
}
<<< AvoidInfix with match within applyinfix
rewrite.rules = [AvoidInfix]
===
object a {
a b c match {
case _ =>
} d e
}
>>>
object a {
(
a.b(c) match {
case _ =>
}
).d(e)
}
<<< AvoidInfix with match, with dot
rewrite.rules = [AvoidInfix]
===
object a {
(a.b(c)).match
case _ =>
}
>>>
object a {
(a.b(c)).match
case _ =>
}
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, 1082944, "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