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

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

Closed
martijnhoekstra opened this issue Jun 19, 2024 · 5 comments

Comments

@martijnhoekstra
Copy link
Contributor

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
Copy link
Contributor Author

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

@lloydmeta
Copy link
Owner

That is odd.

Would def appreciate your help on this one.

val (valueField, valueParamIndex): (Symbol, Int) = {
if (enumFields.size == 1) {
enumFields.headOption
} else {
enumFields.find(_._1.name == "value")
}
}.getOrElse {
Symbol.newVal(tpeSym, "value", valueRepr, Flags.Abstract, Symbol.noSymbol) -> 0
}

^ seems like a relevant area.

@martijnhoekstra
Copy link
Contributor Author

I took a stab at #397, but I find it very difficult to get tests to consistently run locally on scala 3

@martijnhoekstra
Copy link
Contributor Author

#398 should be better.

@lloydmeta
Copy link
Owner

Done via #398

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

No branches or pull requests

2 participants