Reputation: 3131
I have a trait that looks like this:
trait Processor[+T <: Document] {
def process[D >: T <: Document](doc: D)
}
If I declare the process
method with process[D >: T](doc: D)
, I can't access the methods from the Document
class.
I don't know why do I need to repeat the upper bound, the <: Document
, in the process
method.
So, two questions:
Upvotes: 1
Views: 120
Reputation: 5315
The upper bound in your method is on D
, not on T
. Say you do not put that upper bound, then D
could be anything that T
also is, for instance, Any
. So the compiler must assume that D
could be Any
, and therefore cannot give you more methods.
Upvotes: 2