I'm trying to extend the SecureAction of the pac4j-play module, because i want some extra stuff validated and added to the request, for easy access in the controller.
But i run into a type-mismatch compilation issue, and i cannot seem to grasp why.
class SecureSiteAction[P<:CommonProfile, ContentType, R[X]>:AuthenticatedRequest[P, X]<:Request[X]](clients: String, authorizers: String, matchers: String, multiProfile: Boolean, parser: BodyParser[ContentType], playSessionStore: PlaySessionStore, config: Config)(implicit implicitExecutionContext: ExecutionContext)
extends SecureAction[P, ContentType, R](clients, authorizers, matchers, multiProfile, parser, playSessionStore, config) {
override def invokeBlock[A](request: Request[A], block: R[A] => Future[Result]): Future[Result] = {
super.invokeBlock(request, { request: R[A] =>
val site = Site(request.host)
val profiles = request.asInstanceOf[AuthenticatedRequest[P, A]].profiles
block(AuthenticatedSiteRequest(site, profiles, request))
})
}
}
case class AuthenticatedSiteRequest[P<:CommonProfile, +A](site: Site, profiles: List[P], request: Request[A]) extends WrappedRequest[A](request)
I have imported stuff like import scala.language.higherKinds
and the rest from the original SecureAction
class (see https://github.com/pac4j/play-pac4j/blob/master/shared/src/main/scala/org/pac4j/play/scala/Security.scala).
the following line is the issue:
block(AuthenticatedSiteRequest(site, profiles, request))
which gives the type error:
type mismatch;
[error] found : binders.AuthenticatedSiteRequest[P,A]
[error] required: R[A]
[error] block(AuthenticatedSiteRequest(site, profiles, request))
The "funny" thing is, that when i copy/paste the source code directly from pac4j-play's SecureAction
case class into my IDE, i get the exact same compilation error.
What can make this compile? Is it a flag in sbt, or something i don't know about?