weaver-test icon indicating copy to clipboard operation
weaver-test copied to clipboard

circe json string interpolator does not work when invoiced directly via a wrapper class

Open hoshikon opened this issue 1 year ago • 0 comments

This does not compile:

test("This does not compile") {
    import io.circe.Json
    import io.circe.literal.json
    case class Wrapper(json: Json)

    expect(Wrapper(json"{}").json == Json.obj())
}

error:

[error] 670 |    expect(Wrapper(json"{}").json == Json.obj())
[error]     |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]     |    Found:    (String, io.circe.Json)*
[error]     |    Required: (String, io.circe.Json)
[error]     |---------------------------------------------------------------------------
[error]     |Inline stack trace
[error]     |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]     |This location contains code that was inlined from JsonLiteralMacros.scala:91
[error]      ---------------------------------------------------------------------------
[error]     |
[error]     | longer explanation available when compiling with `-explain`

Whereas this does:

test("blah".only) {
    import io.circe.Json
    import io.circe.literal.json
    case class Wrapper(json: Json)

    val wrapper = Wrapper(json"{}")
    expect(wrapper.json == Json.obj())
}

hoshikon avatar Jan 08 '25 10:01 hoshikon