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

RemoveScala3OptionalBraces: allow leading infix op #3840

Merged
merged 1 commit into from Mar 17, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -76,7 +76,9 @@ private class RemoveScala3OptionalBraces(implicit val ftoks: FormatTokens)
case t: Term.Name =>
t.parent.exists {
case p: Term.Select => p.name eq t // select without `.`
case p: Term.ApplyInfix => p.op eq t
case p: Term.ApplyInfix if p.op eq t =>
!style.dialect.allowInfixOperatorAfterNL ||
!t.tokens.head.isSymbolicInfixOperator
case _ => false
}
case _ => false
Expand Down
8 changes: 4 additions & 4 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat
Expand Up @@ -5211,10 +5211,10 @@ object a:
withEval.so(evalComment so { c =>
s"($c) "
}) +
this.match {
case MateAdvice(seq, _, _, _) => seq.desc
case CpAdvice(judgment, _, _) => judgment.toString
} + "."
this.match
case MateAdvice(seq, _, _, _) => seq.desc
case CpAdvice(judgment, _, _) => judgment.toString
+ "."
<<< match as infix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
Expand Down
Expand Up @@ -4981,10 +4981,10 @@ object a {
}
>>>
object a:
withEval.so(evalComment so { c => s"($c) " }) + this.match {
case MateAdvice(seq, _, _, _) => seq.desc
case CpAdvice(judgment, _, _) => judgment.toString
} + "."
withEval.so(evalComment so { c => s"($c) " }) + this.match
case MateAdvice(seq, _, _, _) => seq.desc
case CpAdvice(judgment, _, _) => judgment.toString
+ "."
<<< match as infix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
Expand Down
Expand Up @@ -5246,10 +5246,10 @@ object a:
withEval.so(evalComment so { c =>
s"($c) "
}) +
this.match {
case MateAdvice(seq, _, _, _) => seq.desc
case CpAdvice(judgment, _, _) => judgment.toString
} + "."
this.match
case MateAdvice(seq, _, _, _) => seq.desc
case CpAdvice(judgment, _, _) => judgment.toString
+ "."
<<< match as infix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
Expand Down
Expand Up @@ -5373,12 +5373,12 @@ object a:
s"($c) "
}
) +
this.match {
case MateAdvice(seq, _, _, _) =>
seq.desc
case CpAdvice(judgment, _, _) =>
judgment.toString
} + "."
this.match
case MateAdvice(seq, _, _, _) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have 3 spaces here? It should stay the same, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because significant indentation in this file is set to 3:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ach! Right

seq.desc
case CpAdvice(judgment, _, _) =>
judgment.toString
+ "."
<<< match as infix lhs, with rewrite
rewrite.scala3.removeOptionalBraces = yes
===
Expand Down