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

Members of enums nested in a class are not discovered in scala 3 #384

Open
mrdziuban opened this issue Nov 15, 2023 · 1 comment
Open

Members of enums nested in a class are not discovered in scala 3 #384

mrdziuban opened this issue Nov 15, 2023 · 1 comment

Comments

@mrdziuban
Copy link
Contributor

In this example case object a is discovered by findValues on scala 2, but is not on scala 3

https://scastie.scala-lang.org/mrdziuban/UeKyIrUZTi2ulDq9U89lmw/5

import enumeratum.{Enum, EnumEntry}

class Test() {
  sealed trait Foo extends EnumEntry
  object Foo extends Enum[Foo] {
    lazy val values = findValues
    case object a extends Foo
  }
}

val test = new Test()
test.Foo.values // Vector(): scala.collection.immutable.IndexedSeq[test.Foo]
@mrdziuban mrdziuban changed the title Members of an enums nested in a class are not discovered in scala 3 Members of enums nested in a class are not discovered in scala 3 Nov 15, 2023
@lloydmeta
Copy link
Owner

lloydmeta commented Nov 15, 2023

I'm actually surprised that nesting enums inside a class this is even a thing, as it brings to mind the question of things like whether the enum is owned by each instance of a class or whether it's "static". EDIT for clarity: should (new Test).Foo.a == (new Test).Foo.a???

In any case, I'm open to considering this something to "fix" for the sake of BWC with Scala 2, but also open to saying "no" to this and adding, say, a compiler warning for this kind of situation.

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