Skip to content

Instantly share code, notes, and snippets.

@blast-hardcheese
Created September 10, 2015 00:55
Show Gist options
  • Save blast-hardcheese/a9ff3be14f2b052756ea to your computer and use it in GitHub Desktop.
Save blast-hardcheese/a9ff3be14f2b052756ea to your computer and use it in GitHub Desktop.
// Given this definition,
def buildWrites[U, T <: DataTyped[U]](baseWrites: Writes[T])(implicit typeToJs: U => Json.JsValueWrapper): Writes[T]
// Works!
val someWrites: Writes[SomeDataTyped_v1] = DataTyped.buildWrites[FeedEntryTypes.Value, SomeDataTyped_v1](Json.writes[SomeDataTyped_v1])
// Fails.
val someWrites: Writes[SomeDataTyped_v1] = DataTyped.buildWrites(Json.writes[SomeDataTyped_v1])
[error] .../DataSpec.scala:65: type mismatch;
[error] found : play.api.libs.json.Writes[viewmodels.DataTyped[Nothing] with models.artFeed.SomeDataTyped_v1]
[error] required: play.api.libs.json.Writes[models.artFeed.SomeDataTyped_v1]
[error] val someWrites: Writes[SomeDataTyped_v1] = DataTyped.buildWrites(Json.writes[SomeDataTyped_v1])
[error] ^
[error] one error found
[error] (core/test:compile) Compilation failed
[error] Total time: 1 s, completed Sep 9, 2015 5:53:03 PM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment