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

ConvertToNewScala3Syntax bugfix: _ only in types #3303

Merged
merged 2 commits into from
Aug 19, 2022
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 @@ -70,7 +70,9 @@ private class ConvertToNewScala3Syntax(ftoks: FormatTokens)
ft.meta.rightOwner match {
case _: Importee.Wildcard if dialect.allowStarWildcardImport =>
replaceTokenIdent("*", ft.right)
case _: Type.Placeholder if dialect.allowQuestionMarkPlaceholder =>
case t: Type.Placeholder
if dialect.allowQuestionMarkPlaceholder &&
t.parent.exists(_.is[Type]) =>
replaceTokenIdent("?", ft.right)
case _: Term.Repeated if dialect.allowPostfixStarVarargSplices =>
removeToken // see above, under Colon
Expand Down
10 changes: 10 additions & 0 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat
Original file line number Diff line number Diff line change
Expand Up @@ -3554,3 +3554,13 @@ class Foo() {
false
}
}
<<< #3302
rewrite.scala3.convertToNewSyntax = yes
===
type Inner[A] = A match
case Seq[x] => x
case _ => A
>>>
type Inner[A] = A match
case Seq[x] => x
case _ => A
10 changes: 10 additions & 0 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces_fold.stat
Original file line number Diff line number Diff line change
Expand Up @@ -3380,3 +3380,13 @@ class Foo() {
false
}
}
<<< #3302
rewrite.scala3.convertToNewSyntax = yes
===
type Inner[A] = A match
case Seq[x] => x
case _ => A
>>>
type Inner[A] = A match
case Seq[x] => x
case _ => A
10 changes: 10 additions & 0 deletions scalafmt-tests/src/test/resources/scala3/OptionalBraces_keep.stat
Original file line number Diff line number Diff line change
Expand Up @@ -3536,3 +3536,13 @@ class Foo() {
false
}
}
<<< #3302
rewrite.scala3.convertToNewSyntax = yes
===
type Inner[A] = A match
case Seq[x] => x
case _ => A
>>>
type Inner[A] = A match
case Seq[x] => x
case _ => A
Original file line number Diff line number Diff line change
Expand Up @@ -3661,3 +3661,16 @@ class Foo() {
false
}
}
<<< #3302
rewrite.scala3.convertToNewSyntax = yes
===
type Inner[A] = A match
case Seq[x] => x
case _ => A
>>>
type Inner[A] =
A match
case Seq[x] =>
x
case _ =>
A