Skip to content

Commit 8878f31

Browse files
committed
Fix rewrite for type-ascribed refutable pattern binding
1 parent 56ca1ba commit 8878f31

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
15981598
| _: untpd.Match
15991599
| _: untpd.ForYield
16001600
| _: untpd.ParsedTry
1601-
| _: untpd.Try => Some("(", ")")
1601+
| _: untpd.Try
1602+
| _: untpd.Typed => Some("(", ")")
16021603
case _: untpd.Block => Some("{", "}")
16031604
case _ => None
16041605

tests/rewrites/refutable-pattern-bindings.check

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ val j :: k =
2323
(for
2424
case (x: String) <- xs
2525
yield x): @unchecked
26+
27+
val (_: Int | _: AnyRef) = (??? : AnyRef): @unchecked

tests/rewrites/refutable-pattern-bindings.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ val j :: k =
2323
for
2424
(x: String) <- xs
2525
yield x
26+
27+
val (_: Int | _: AnyRef) = ??? : AnyRef

0 commit comments

Comments
 (0)