Skip to content

Commit

Permalink
Add test with parens around types
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Jun 23, 2024
1 parent 43124ab commit 807cdbd
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions scalafmt-tests/src/test/resources/rewrite/RedundantParens.stat
Original file line number Diff line number Diff line change
Expand Up @@ -1410,3 +1410,65 @@ rewrite.rules = [RedundantBraces, RedundantParens]
foo.mtd({ x => x + 1 })
>>>
foo.mtd(x => x + 1)
<<< type in parens, val/var
runner.dialect = scala3
===
object a {
val (a: (Int)) = b
var (c: (foo.Int)) = d
val (a: (A | B)) = b
var (c: (C & D)) = d
val (a: (A | B), c: (C & D)) = (b, d)
}
>>>
object a {
val (a: Int) = b
var (c: (foo.Int)) = d
val (a: (A | B)) = b
var (c: (C & D)) = d
val (a: (A | B), c: (C & D)) = (b, d)
}
<<< type in parens, def
runner.dialect = scala3
===
object a {
def g(h: (Int)): (String)
def g(h: (Int)): (foo.String)
def g(h: (Int)): (foo.String[A])
def g(h: (Int)): (String) = ???
def g(h: (Int)): (foo.String) = ???
def g(h: (Int)): (foo.String[A]) = ???
def g(h: (Int | Long)): (foo & bar) = ???
def g(h: (A & B)): (foo | bar[A]) = ???
}
>>>
object a {
def g(h: Int): String
def g(h: Int): (foo.String)
def g(h: Int): foo.String[A]
def g(h: Int): (String) = ???
def g(h: Int): (foo.String) = ???
def g(h: Int): (foo.String[A]) = ???
def g(h: (Int | Long)): (foo & bar) = ???
def g(h: (A & B)): (foo | bar[A]) = ???
}
<<< type in parens, typedef
runner.dialect = scala3
===
object a {
type f = (bar.Int[baz])
}
>>>
object a {
type f = bar.Int[baz]
}
<<< type in parens, pat
runner.dialect = scala3
===
a match {
case _: (A | B) | _: (C & D) =>
}
>>>
a match {
case _: (A | B) | _: (C & D) =>
}

0 comments on commit 807cdbd

Please sign in to comment.