It looks like you are trying to define a parameter of type, A, sign, AdvertisementDAO, as covariant. Below is a sample code example from the previous answer using the covariance annotation +.
trait Advertisement {} class AdvertisementImpl extends Advertisement{} class CrudRepository[+A,B] {} trait AdvertisementDAO[+A <: Advertisement] extends CrudRepository[A, Integer] {} class AdvertisementDAOImpl[+A <: Advertisement] extends AdvertisementDAO[A]{} class AdvertisementDAOImpl2 extends AdvertisementDAO[AdvertisementImpl]{} class AdvertisementDAOImpl3 extends AdvertisementDAO[Advertisement]{} object Tester { def main(args:Array[String]):Unit = { var advertisementDAO: AdvertisementDAO[Advertisement] = null advertisementDAO = new AdvertisementDAOImpl advertisementDAO = new AdvertisementDAOImpl2 advertisementDAO = new AdvertisementDAOImpl3 } }
Another example of a covariant common is scala.collection.immutable.List. Defining a common (class or trait) C as covariant means that C [S] is a subtype of C [T] if type S is a subtype of type T. For example, AdvertisementDAO [AdvertisementImpl] is a subtype of AdvertisementDAO [Advertising] because AdvertisementImpl is a subtype advertising (as AdvertisingImpl expands advertising). I published an article that contains a tutorial on dispersion, as it happens in many languages (e.g. Scala, C #, Java). Slides are also available for a quick overview. Hope this helps.
source share