How can Seq [+ A] be covariant in A?

As Seq [+ A] is covariant in A if A occurs in a contravariant position:

def :+ (elem: A) : Seq[A] ? 

As I understand it, the type of method argument is a contravariant position. What am I missing?

+6
scala covariance
source share
1 answer

This is a usage signature. This is not a real signature, just what you usually see in the usual case.

Real Signature:

 def :+ [B >: A, That] ( elem : B )(implicit bf : CanBuildFrom[Seq[A], B, That] ) : That 

Which, as you can see, does not even guarantee the return of Seq , and even more so A

+10
source share

All Articles