Closed as not planned
Description
Compiler version
3.3.5
Minimized code
trait A:
def a: Unit
trait B:
def b: Unit
class ABImpl extends A, B:
def a: Unit = println("a")
def b: Unit = println("b")
// Compiles when a type alias is used
type AB = A & B
given namedGivenWithTypeAlias: AB = ABImpl()
given AB = ABImpl()
// Compiles with parentheses
given namedGivenWithParentheses: (A & B) = ABImpl()
given (A & B) = ABImpl()
// Does not compile when & is used inline
given namedGivenInline: A & B = ABImpl()
given A & B = ABImpl()
Output
[error] ./test.scala:24:27
[error] 'with' expected, but identifier found
[error] given namedGivenInline: A & B = ABImpl()
[error] ^
[error] ./test.scala:25:9
[error] 'with' expected, but identifier found
[error] given A & B = ABImpl()
[error] ^
Error compiling project (Scala 3.3.5, JVM (21))
Expectation
given namedGivenInline: A & B = ABImpl()
and given A & B = ABImpl()
should compile as valid given declarations.