Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

constValue for singleton enum cases #121

Open
letalvoj opened this issue May 24, 2020 · 1 comment
Open

constValue for singleton enum cases #121

letalvoj opened this issue May 24, 2020 · 1 comment

Comments

@letalvoj
Copy link

Let's have an enum

enum E:
  case C

I'd expect one of the following to be possible:

  • constValue[E.C.type] should provide C and other parameter-less cases
  • Mirror.Sum should have valueOf, the same way how E has valueOf

None of the above is present in dotty as of now.

Use case - I have a bunch of enums for which I want to derive a type-class. The mapping is the very simplest possible - the name of the enum value determines the target instance. Hence the usage of the valueOf, or any other way of instantiating the enum case based on name only.

@letalvoj letalvoj changed the title Access to enum values from generic functions constValue for singleton enum cases May 24, 2020
@bishabosha
Copy link
Member

so currently constValue is only for things that have literal types. You can still use Predef.valueOf[E.C.type] or with any other singleton type

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

No branches or pull requests

2 participants