我在scala中有以下函数定义:
trait GenExtractor[+R] P
def orElseExtractor[R2<: Super, Super>: R](g: GenExtractor[T, R2]): GenExtractor[T, Super] =
new OrElse[T, Super](this, g)
}
这应该结合2个GenExtractors:
GenExtractor[A]
GenExtractor[B]
进入:
GenExtractor[C]
其中 C 是 A 和 B 的共同超类型
但是,当我尝试调用此函数时:
val genExtractor = new GenExtractor[R](...parameters...)
val combined = genExtractor.orElseExtractor[Null, R] {
_: FetchedRow => null
}
我收到以下错误:
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] {
^
这显然是一个误报,因为在这种情况下:
type R2 = Null
type Super = R
满足条件:Null <: R & R >: R
为什么scala编译器给了我这个错误?我应该怎么做才能修复它?