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

Derived Configs for a sealed trait does not search for other implicits #28

Open
steinybot opened this issue May 3, 2018 · 0 comments
Open

Comments

@steinybot
Copy link

Implicits are not resolved when automatically deriving Configs for a sealed trait:

case class A1(b: B1)

object A1 {

  implicit val cConfigs: Configs[C1] = {
    (c, _) => c.get[String]("d").map(C1.make)
  }
  implicit val bConfigs: Configs[B1] = Configs.autoDeriveConfigs[B1]
  implicit val aConfigs: Configs[A1] = Configs.autoDeriveConfigs[A1]
}

sealed trait B1

class C1 private(val d: String) extends B1

object C1 {

  def make(d: String): C1 = new C1(d)
}

This fails with:

[error] C1 has no public constructor
[error]   implicit val bConfigs: Configs[B1] = Configs.autoDeriveConfigs[B1]
[error]                                                                 ^

The simple case works:

case class A2(b: B2)

object A2 {

  implicit val aConfigs: Configs[A2] = Configs.autoDeriveConfigs[A2]
}

sealed trait B2

case class C2(d: String) extends B2

We can show that implicits are resolved when automatically deriving Configs for a case class:

case class A3(b: C3)

object A3 {

  implicit val cConfigs: Configs[C3] = {
    (c, _) => c.get[String]("d").map(C3.make)
  }
  implicit val aConfigs: Configs[A3] = Configs.autoDeriveConfigs[A3]
}

class C3 private(val d: String)

object C3 {

  def make(d: String): C3 = new C3(d)
}
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