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

scala3 rewrite: do not rewrite _* unless bind #2975

Merged
merged 2 commits into from
Dec 20, 2021
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 @@ -72,9 +72,12 @@ private class ConvertToNewScala3Syntax(ftoks: FormatTokens)
replaceTokenIdent("*", ft.right)
case _: Type.Placeholder if dialect.allowQuestionMarkPlaceholder =>
replaceTokenIdent("?", ft.right)
case _: Term.Repeated | _: Pat.SeqWildcard
if dialect.allowPostfixStarVarargSplices =>
removeToken // see above, under Colon and At
case _: Term.Repeated if dialect.allowPostfixStarVarargSplices =>
removeToken // see above, under Colon
case t: Pat.SeqWildcard
if dialect.allowPostfixStarVarargSplices &&
t.parent.exists(_.is[Pat.Bind]) =>
removeToken // see above, under At
case _ => null
}

Expand Down
12 changes: 12 additions & 0 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat
Original file line number Diff line number Diff line change
Expand Up @@ -2970,3 +2970,15 @@ object a {
} a +
b
}
<<< do not rewrite vararg-splice unless bind-wildcard
rewrite.scala3.convertToNewSyntax = true
===
foo {
case bar @ baz(_*) => qux
case baz @ baz(x @ _*) => qux
}
>>>
foo {
case bar @ baz(_*) => qux
case baz @ baz(x*) => qux
}