I have the following function definition in scala:
trait GenExtractor[+R] P
def orElseExtractor[R2<: Super, Super>: R](g: GenExtractor[T, R2]): GenExtractor[T, Super] =
new OrElse[T, Super](this, g)
}
which should combine 2 GenExtractors:
GenExtractor[A]
GenExtractor[B]
into:
GenExtractor[C]
where C is the common supertype of A and B
However, when I try to invoke this function:
val genExtractor = new GenExtractor[R](...parameters...)
val combined = genExtractor.orElseExtractor[Null, R] {
_: FetchedRow => null
}
I got the following error:
Error:(84, 47) type arguments [Null,R] do not conform to method orElseExtractor's type parameter bounds [R2 <: Super,Super >: R]
def orNull: Extractor[R] = orElseExtractor[Null, R] {
^
This is clearly a false alarm since in this case:
type R2 = Null
type Super = R
which fulfil the condition: Null <: R & R >: R
Why is scala compiler gave me this error? What should I do to fix it?