Closed
Description
Compiler version
3.3.1, 3.4.0-RC1-bin-20240109-91db06a-NIGHTLY
Minimized code
trait JsValue
trait JsObject extends JsValue
trait JsonWriter[T]
trait BodySerializer[-B]
class JsonPrinter
given JsonWriter[JsValue] = ???
given JsonWriter[JsObject] = ???
given[B : JsonWriter](using printer: JsonPrinter = new JsonPrinter): BodySerializer[B] = ???
def f: Unit =
summon[BodySerializer[JsObject]]
Output
[error] No given instance of type BodySerializer[JsObject] was found for parameter x of method summon in object Predef.
[error] I found:
[error]
[error] given_BodySerializer_B[B]()
[error]
[error] But given instance given_BodySerializer_B does not match type BodySerializer[JsObject].
[error] summon[BodySerializer[JsObject]]
[error] ^
Expectation
[error] Ambiguous given instances: both given instance given_JsonWriter_JsValue and given instance given_JsonWriter_JsObject match type JsonWriter[B] of parameter x of method summon in object Predef
[error] summon[BodySerializer[JsObject]]
[error] ^
note: the expectation is what I got when I removed the implicit JsonPrinter
parameter from the given BodySerializer
:
given[B : JsonWriter]: BodySerializer[B] = ???