Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal error on Scala 2.13 given generic JsonValueCodec to be used transitively #1245

Open
tribbloid opened this issue Jan 30, 2025 · 1 comment

Comments

@tribbloid
Copy link

tribbloid commented Jan 30, 2025

Code example:

trait Imp0 {

  case class User(
      name: String,
      age: Int,
      path: Path = Path.of("http://google.com")
  )

  implicit def pojoCodec[T <: AnyRef]: JsonValueCodec[T] = {

    print_@("pojo")
    ???
  } // fallback to jackson here

  implicit lazy val pojoCodec2: JsonValueCodec[AnyRef] = { // only works iif JsonValueCodec is contravariant

    print_@("pojo")
    ???
  } // fallback to jackson here
}

object JsoniterFallbackExample extends Imp0 {

  // Generate codec for Person (automatically handles Address too)
  implicit lazy val personCodec: JsonValueCodec[User] = JsonCodecMaker.make
}

The intention is to use Jackson to handle Java Path which is not a Scala product type. When compiling, it generates the following error:

[Error] /home/peng/git/scalaspike/common/generic/src/test/scala/com/tribbloids/spike/generic/jsoniter/JsoniterFallbackExample.scala:34:72: Internal error: unable to find the outer accessor symbol of <$anon: com.github.plokhotnyuk.jsoniter_scala.core.JsonValueCodec>
one error found

What is "outer accessor symbol" here? Can the internal error stack trace be reported and potentially be used in telemetry?

@plokhotnyuk
Copy link
Owner

It is a known issue num. 3: https://github.com/plokhotnyuk/jsoniter-scala?tab=readme-ov-file#known-issues

What you see is an internal error from the scalac.

Feel free to mitigate in your code by moving your data classes out a trait or contribute some mitigations to jsoniter-scala macros (or even scalac if the root cause is in its side).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants