it's slightly unfortunate that you can't do: ``` @...
# squarelibraries
e
it's slightly unfortunate that you can't do:
Copy code
@FromJson
private fun fromJson(
  response: Response,
  circleAdapter: JsonAdapter<Layer.Circle>,
  rectangleAdapter: JsonAdapter<Layer.Rectangle>,
  squareAdapter: JsonAdapter<Layer.Square>
): Layer {
  return when (response) {
    TypeEnum.circle -> circleAdapter.fromJsonValue(response.layer)!!
    TypeEnum.rectangle -> rectangleAdapter.fromJsonValue(response.layer)!!
    TypeEnum.square -> squareAdapter.fromJsonValue(response.layer)!!
  }
}
and instead have to do:
Copy code
@FromJson
private fun fromJson(
  reader: JsonReader,
  responseAdapter: JsonAdapter<Response>,
  circleAdapter: JsonAdapter<Layer.Circle>,
  rectangleAdapter: JsonAdapter<Layer.Rectangle>,
  squareAdapter: JsonAdapter<Layer.Square>
): Layer {
  val response = responseAdapter.fromJson(reader)!!
  return when (response.type) {
    TypeEnum.circle -> circleAdapter.fromJsonValue(response.layer)!!
    TypeEnum.rectangle -> rectangleAdapter.fromJsonValue(response.layer)!!
    TypeEnum.square -> squareAdapter.fromJsonValue(response.layer)!!
  }
}
but polymorphic stuff is rare enough. responded with a working test case on your gist.