Open
Description
Compiler version
scala-cli --version
Scala CLI version: 1.2.1
Scala version (default): 3.4.1
Minimized example
trait A
trait B
class C extends A with B
def test(o: AnyRef): Int =
o match {
case c: A with B => 1
}
println(test(C()))
Output
Compiling project (Scala 3.4.1, JVM (21))
[warn] ./repro.sc:7:15
[warn] with as a type operator has been deprecated; use & instead
[warn] This construct can be rewritten automatically under -rewrite -source 3.4-migration.
[warn] case c: A with B => 1
[warn] ^^^^
Compiled project (Scala 3.4.1, JVM (21))
1
After updating the code:
Compiling project (Scala 3.4.1, JVM (21))
[error] ./repro.sc:7:15
[error] '=>' expected, but identifier found
[error] case c: A & B => 1
[error] ^
Error compiling project (Scala 3.4.1, JVM (21))
Compilation failed
Workaround is to add parenthesis:
case c: (A & B) => 1
Expectation
Rewrite automatically adds parenthesis, or the compiler doesn't require them