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

Scala3: findValues fails to compile in nested sealed trait hierarchy #368

Closed desavitsky closed 11 months ago

desavitsky commented 12 months ago

Example:

import enumeratum.values.StringEnum
import enumeratum.values.StringEnumEntry

sealed trait FirstLevel extends StringEnumEntry

object FirstLevel extends StringEnum[FirstLevel] {

  case object One extends FirstLevel {
    val value = "one"
  }
  case object Two extends FirstLevel {
    val value = "two"
  }

  sealed trait SecondLevel extends FirstLevel

  case object Three extends SecondLevel {
    val value = "three"
  }

  override def values: IndexedSeq[FirstLevel] = findValues

}

https://scastie.scala-lang.org/qpDNUwqAT4m4ovmn4EySgg

Error: Exception occurred while executing macro expansion. scala.MatchError: Type.of[...] (of class scala.quoted.runtime.impl.TypeImpl)

lloydmeta commented 12 months ago

Interesting... looks like the collect method is missing this possible case for tupleTpe:

https://github.com/lloydmeta/enumeratum/blob/f9b528ae9e063ae2617a9b8f3232639e48f4763a/macros/src/main/scala-3/enumeratum/ValueEnumMacros.scala#L188-L241