wix-incubator / accord

Accord: A sane validation library for Scala
http://wix.github.io/accord/
Other
530 stars 55 forks source link

NoSuchMethodError when creating implicit validator #123

Open buildreactive opened 6 years ago

buildreactive commented 6 years ago

I'm getting the following error:

java.lang.NoSuchMethodError: scala.collection.immutable.$colon$colon.tl$1()Lscala/collection/immutable/List;
    at com.wix.accord.transform.FunctionDescriber$class.describeFunction(ExpressionDescriber.scala:145)
    at com.wix.accord.transform.ValidationTransform.describeFunction(ValidationTransform.scala:24)
    at com.wix.accord.transform.ValidationTransform.<init>(ValidationTransform.scala:36)
    at com.wix.accord.transform.ValidationTransform$.apply(ValidationTransform.scala:240)

When attempting to create the following validator:

object foo {
    implicit val shipValidator = validator[Ship] { p =>
        p.summary.code.length is between(1, 4) // The expression being validated is resolved automatically, see below
        p.summary.code should matchRegex(".*")
        p.summary.paxCapacity as "ship code" should be > 5 // You can also explicitly describe the expression being validated
    }
}

For the following class:

case class Ship(
    summary: ShipSummary,
    detail: ShipDetail,
    decks: Decks,
    fireZones: FireZones,
    shipsTime: Option[Instant]
) {
    def safeId = summary.id.getOrElse(UUID.randomUUID())
}

object Ship {
    type LegacyID = Map[String, String]
    type Attributes = Map[String, String]
    //... some other stuff
    implicit val optionString: Format[Ship] = Json.format
}
holograph commented 6 years ago

Thanks for reporting, I'll look into it shortly (things are a little sluggish these days because of the transfer of ownership, but will sort themselves out soon)

holograph commented 6 years ago

I can't seem to reproduce this; can you specify which versions of Accord, Scala and JDK you're using?

holograph commented 6 years ago

Perhaps you are compiling with Scala 2.12.5 with JDK 9/10? It has a known regression with macros: https://github.com/scala/scala/releases/tag/v2.12.5

buildreactive commented 6 years ago

Nope. 12.2.6 and JDK 8.

holograph commented 6 years ago

@zbeckman Hold on, is this at compile or runtime?