Created
March 7, 2014 12:04
-
-
Save robertberry-zz/9410272 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[info] Compiling 9 Scala sources to /home/robert/Git/mobile-apps-api/common/target/scala-2.10/classes... | |
[error] /home/robert/Git/mobile-apps-api/common/app/lib/PlayJson.scala:17: type mismatch; | |
[error] found : (play.api.libs.json.Reads[Nothing], play.api.libs.json.Reads[Nothing]) => play.api.libs.json.Reads[Nothing] | |
[error] required: (play.api.libs.json.Reads[_ <: A], play.api.libs.json.Reads[_ <: A]) => play.api.libs.json.Reads[_ <: A] | |
[error] def oneOf[A](reads: Seq[Reads[_ <: A]]): Reads[A] = reads.reduce(either) | |
[error] ^ | |
[error] /home/robert/Git/mobile-apps-api/common/app/lib/PlayJson.scala:17: type mismatch; | |
[error] found : play.api.libs.json.Reads[_$1] where type _$1 <: A | |
[error] required: play.api.libs.json.Reads[A] | |
[error] Note: _$1 <: A, but trait Reads is invariant in type A. | |
[error] You may wish to define A as +A instead. (SLS 4.5) | |
[error] def oneOf[A](reads: Seq[Reads[_ <: A]]): Reads[A] = reads.reduce(either) |
// Reads is covariant, dunno why it isn't.
def readsUpCast[A](r: Reads[_ <: A]): Reads[A] = r.map(x => x)
def mapx[A](reads: Seq[Reads[_ <: A]]): Seq[Reads[A]] = reads.map(readsUpCast[A] _)
def oneOf[A](reads: Seq[Reads[_ <: A]]): Reads[A] = mapx[A](reads).reduce(_ orElse _)
Let's see if someone wiser could answer: http://stackoverflow.com/questions/25567572/why-reads-is-not-declared-covariant
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PLAY SUCKS DAMMIT