I am getting the following error in my Play
, Silhouette
, Cassandra
application
class UsersRepository needs to be abstract, since: it has 6 unimplemented members.
/** As seen from class UsersRepository, the missing signatures are as follows. * For convenience, these are usable as stub implementations. */ // Members declared in com.mohiva.play.silhouette.api.repositories.AuthInfoRepository
def add[T <: com.mohiva.play.silhouette.api.AuthInfo](loginInfo: com.mohiva.play.silhouette.api.LoginInfo,authInfo: T): scala.concurrent.Future[T] = ???
def find[T <: com.mohiva.play.silhouette.api.AuthInfo](loginInfo: com.mohiva.play.silhouette.api.LoginInfo)(implicit tag: scala.reflect.ClassTag[T]): scala.concurrent.Future[Option[T]] = ???
def remove[T <: com.mohiva.play.silhouette.api.AuthInfo](loginInfo: com.mohiva.play.silhouette.api.LoginInfo)(implicit tag: scala.reflect.ClassTag[T]): scala.concurrent.Future[Unit] = ???
def save[T <: com.mohiva.play.silhouette.api.AuthInfo](loginInfo: com.mohiva.play.silhouette.api.LoginInfo,authInfo: T): scala.concurrent.Future[T] = ???
def update[T <: com.mohiva.play.silhouette.api.AuthInfo](loginInfo: com.mohiva.play.silhouette.api.LoginInfo,authInfo: T): scala.concurrent.Future[T] = ???
However, in the same file, I have implemented them
class UsersRepository(session: Session)
extends CassandraRepository[UserKeys,User](session, "users", List("bucket","email")) with UserDao with AuthInfoRepository {
def find(loginInfo:LoginInfo):Future[Option[PasswordInfo]] = Future {
... }
def add(loginInfo:LoginInfo, authInfo:PasswordInfo):Future[PasswordInfo] = Future {
...
}
def update(loginInfo:LoginInfo, authInfo:PasswordInfo):Future[PasswordInfo] = {
add(..)//add returns a Future
...}
def save(loginInfo:LoginInfo, authInfo:PasswordInfo):Future[PasswordInfo] = {
add(..)//add returns a Future
}
def remove(loginInfo:LoginInfo):Future[Unit] = Future{
...
}
}
What am I doing wrong?
Well, you actually didn't override them:
def add[T <: AuthInfo](
loginInfo: LoginInfo,
authInfo: T
): Future[T]
vs
def add(
loginInfo:LoginInfo,
authInfo: PasswordInfo
):Future[PasswordInfo]
The former takes anything that can be an instance of AuthInfo
, the latter a very specific case where it is exactly PasswordInfo
.
When you mix OOP into it, e.g. upcasting to the parental interface, the specialization might not be actually visibly and compiler will have to use generic (unimplemented) method.
In such cases it is safer to add override
keyword and be sure that you are actually overriding the ???
implementation.