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

[pureconfig] Refined cannot be read inside a Collection inside a Case Class inside a Collection #657

Open
gaelrenoux opened this issue Jul 15, 2019 · 0 comments

Comments

@gaelrenoux
Copy link

gaelrenoux commented Jul 15, 2019

Sorry about the long title, but this is a weird one and I wasn't sure how to name that.

I had the problem in my configuration, here's a simplified version:

object Test {

  import pureconfig.generic.auto._
  import eu.timepit.refined.pureconfig._

  // I tried removing the refined import and explicitly declaring the implicit, but it didn't change anything
  /* implicit val evidence: ConfigConvert[NonEmptyString] = new ConfigConvert[NonEmptyString] {
    override def to(a: NonEmptyString): ConfigValue = ???
    override def from(cur: ConfigCursor): Result[NonEmptyString] = ???
  } */

  implicit val evidenceMg: ConfigConvert[McGuffin] = new ConfigConvert[McGuffin] {
    override def to(a: McGuffin): ConfigValue = ???
    override def from(cur: ConfigCursor): Result[McGuffin] = ???
  }

  case class TestedNes(a: Set[NonEmptyString])
  case class TestedNesList(a: List[NonEmptyString])
  case class TestedPi(a: Set[PosInt])
  case class TestedMg(a: Set[McGuffin])
  class McGuffin

  def successWithList = loadConfig[List[TestedNes]]
  def successWithListInside = loadConfig[Set[TestedNesList]]
  def successWithoutCollection = loadConfig[TestedNes]
  def successWithoutCaseClass = loadConfig[Set[Set[NonEmptyString]]]
  def successWithoutRefined = loadConfig[Set[TestedMg]]

  def failureWithNonEmptyString = loadConfig[Set[TestedNes]]
  def failureWithPosInt = loadConfig[Set[TestedPi]]
}

The definitions of failureWithPosInt and failureWithNonEmptyString do not compile.The same problem exists with Seq instead of Set, but it goes away with List either on the inner or the outer collection (so there's a workaround, but I'd rather have Sets as that's what makes sense in my model). It is linked to Refined somehow, as using a random class instead didn't fail (whether I'm using Set or Seq), but I just can't see how.

I'm using version 0.9.8 with refined-scalaz, refined-pureconfig and refined-scopt.

@gaelrenoux gaelrenoux changed the title [pureconfig] Refined cannot be read inside a Collection inside a Product inside a Collection [pureconfig] Refined cannot be read inside a Collection inside a Case Class inside a Collection Jul 15, 2019
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

1 participant