Two equal (?) declarations, only one compiles. why?

i can’t figure out the rule here:

this compiles

trait UpdateOutletAssignment[R <: MongoRecord[R] with HasOutlet[R] with HasDealer[R], T <: HasOrIsRecord[R]] extends CSVMeta[T] {

while this doesn’t

trait UpdateOutletAssignment[R <: MongoRecord[R], T <: HasOrIsRecord[R with HasOutlet[R] with HasDealer[R]]] extends CSVMeta[T] {

the error is the case if failure is

type arguments [R with net.veact.util.db.HasOutlet[R] with net.veact.util.db.HasDealer[R]] do not conform to trait HasOrIsRecord’s type parameter bounds [T <: net.liftweb.mongodb.record.MongoRecord[T]]
[error] trait UpdateOutletAssignment[R <: MongoRecord[R], T <: HasOrIsRecord[R with HasOutlet[R] with HasDealer[R]]] extends CSVMeta[T] {

the problematic trait is defind as

trait HasOrIsRecord[T <: MongoRecord[T]]

in summary, this works:

trait Foo[A <: X with Y, B <: C[A]]

while this doesn’t

trait Foo[A <: X, B <: C[A with Y]]

if C is defined as trait C[T <: X]

why? the final type parameter of B is the exact same

Your simplified example just works.

An isolated reproducible version of your problem would be this:

scala> trait X[U]; trait Y; trait C[T <: X[T]]
defined trait X
defined trait Y
defined trait C

scala> trait Foo[A <: X[A] with Y, B <: C[A]]
defined trait Foo

scala> trait Foo[A <: X[A], B <: C[A with Y]]
<console>:14: error: type arguments [A with Y] do not conform to trait C's type parameter bounds [T <: X[T]]
       trait Foo[A <: X[A], B <: C[A with Y]]
                                 ^

The difference here is this.
In the first Foo you pass A to C. A is a subtype of X[A] with Y, which is a subtype of X[A]. So that’s fine.
In the second Foo you pass A with Y to C. But A with Y is not a subtype of X[A with Y].