diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index eb0b92358db8..a0058233588a 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1598,7 +1598,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer | _: untpd.Match | _: untpd.ForYield | _: untpd.ParsedTry - | _: untpd.Try => Some("(", ")") + | _: untpd.Try + | _: untpd.Typed => Some("(", ")") case _: untpd.Block => Some("{", "}") case _ => None diff --git a/tests/rewrites/refutable-pattern-bindings.check b/tests/rewrites/refutable-pattern-bindings.check index 5acea5dc0ead..de61b29ebdf7 100644 --- a/tests/rewrites/refutable-pattern-bindings.check +++ b/tests/rewrites/refutable-pattern-bindings.check @@ -23,3 +23,5 @@ val j :: k = (for case (x: String) <- xs yield x): @unchecked + +val (_: Int | _: AnyRef) = (??? : AnyRef): @unchecked diff --git a/tests/rewrites/refutable-pattern-bindings.scala b/tests/rewrites/refutable-pattern-bindings.scala index e724c9564bd2..eb796662e207 100644 --- a/tests/rewrites/refutable-pattern-bindings.scala +++ b/tests/rewrites/refutable-pattern-bindings.scala @@ -23,3 +23,5 @@ val j :: k = for (x: String) <- xs yield x + +val (_: Int | _: AnyRef) = ??? : AnyRef