Shouldn't R be the lowest common super type of both T and A?
No, because R
is an upper bound. R
can be any super class of T
, and the only class that satisfies that bound is Any
.
Imagine, for instance, that R
was AnyRef
-- you could then call methods such as eq
on it, which would break if an Int
was passed.
So, while R
can be something lower than Any
(and probably will be most of the time), at the time you declare it one cannot assume it to be anything lower than Any
.
However, I think the above has nothing whatsoever to do with your problem. The errors you report appear in these lines, right?
Array[R](x) |: this
this :| Array[R](x)
The other one also has an :|
in it. You don't show any implicit conversion from Array
to Build
, and none of the :|
methods take an Array
as parameter (arrays are not IndexedSeq
).
So, when you write
this :| Array[R](x)
This would call def |: [R1 >: T : ClassManifest, A <: R1] (x: A): BlockList[R1]
(I've changed R
to R1
nto to confuse with the R
in the parameter), where the type of A
is Array[R]
, and the only supertype of T
and Array[R]
is Any
, so R1
has to be Any
, but that Any
is different than R
.
Perhaps, if you called it this.:|[R, Array[R]](Array[R](x)), it would move things a little further. With the missing definitions that allow
Array` to be passed, I can't predict much else.