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

Name clash for derived ADTs? #1378

Closed
an-tex opened this issue Jan 31, 2020 · 1 comment
Closed

Name clash for derived ADTs? #1378

an-tex opened this issue Jan 31, 2020 · 1 comment

Comments

@an-tex
Copy link

an-tex commented Jan 31, 2020

Consider the following minimal example:

import io.circe.Codec
import io.circe.generic.semiauto._

sealed trait Parent

object Nested1 {
  case object Child extends Parent
}

object Nested2 {
  // compiles
  //case object Child1 extends Parent

  // doesn't compile
  case object Child extends Parent
}

implicit val codec: Codec[Parent] = deriveCodec

This doesn't compile with could not find Lazy implicit value of type io.circe.generic.codec.DerivedAsObjectCodec[A].
I've seen #251 , but this seems rather like a name clash on the object Child. If you rename one of the Child objects to e.g. object Child1, compilation works.

I'm using those objects to structure a hierarchy and scope. But as soon as any of the case classes/objects habe the same name the compiler bails out.

This happens on both 0.12.x and 0.13

@travisbrown
Copy link
Member

This is unfortunate but intentional, given Shapeless's representation for cases like this—see this thread and I think also #454 for some discussion and suggestions about workarounds. I wish we could provide a better error message but I also think that's not possible.

A couple of years ago I opened a Shapeless issue noting the problem, and if the representation changes there it should just work here (but I think that's unlikely to happen at this point).

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

No branches or pull requests

2 participants