lloydmeta / enumeratum

A type-safe, reflection-free, powerful enumeration implementation for Scala with exhaustive pattern match warnings and helpful integrations.
MIT License
1.18k stars 146 forks source link

Scala 3 ValueEnum only finds values if the value constructor parameter is first #396

Closed martijnhoekstra closed 1 day ago

martijnhoekstra commented 2 weeks ago
sealed abstract class MyStatus(final val idx: Int, final val value: String) extends StringEnumEntry

object MyStatus extends StringEnum[MyStatus] {
  case object PENDING extends MyStatus(1, "PENDING")
  val values = findValues
}

results in

Fails to check value entry MyStatus.PENDING for enum MyStatus

Switching the constructor params fixes the problem.

martijnhoekstra commented 2 weeks ago

I intend to take a quick look myself, hopefully this is relatively easy

lloydmeta commented 2 weeks ago

That is odd.

Would def appreciate your help on this one.

https://github.com/lloydmeta/enumeratum/blob/1fbbd04426480ee99df6f05a03ad54befe124dd9/macros/src/main/scala-3/enumeratum/ValueEnumMacros.scala#L155-L163

^ seems like a relevant area.

martijnhoekstra commented 2 weeks ago

I took a stab at https://github.com/lloydmeta/enumeratum/pull/397, but I find it very difficult to get tests to consistently run locally on scala 3

martijnhoekstra commented 2 weeks ago

https://github.com/lloydmeta/enumeratum/pull/398 should be better.

lloydmeta commented 1 day ago

Done via #398