softwaremill / magnolia

Easy, fast, transparent generic derivation of typeclass instances
https://softwaremill.com/open-source/
Apache License 2.0
764 stars 116 forks source link

Annotaions that are attached to the enum elements are not visible #491

Open Zhen-hao opened 1 year ago

Zhen-hao commented 1 year ago

While working on https://github.com/sksamuel/avro4s/pull/791 I realized that the 2nd item in the todo list is blocked by the fact we couldn't obtain annotations that are attached to the enum elements via magnolia (1.3.3).

In particular, I'm testing with

import com.sksamuel.avro4s.AvroSortPriority

enum ColoursAnnotatedEnum:
  @AvroSortPriority(0)
  case Red
  @AvroSortPriority(1)
  case Amber
  @AvroSortPriority(2)
  case Green

Is this a well-known issue that won't be fixed in magnolia?

adamw commented 1 year ago

@Zhen-hao no, I can't recall this being a "no-fix" issue :). Parameterless-enums are a bit special (as the cases don't form proper types), so maybe some special-casing needs to be done in the macro. Maybe you'd like to take a stab at trying to fix this?

Zhen-hao commented 1 year ago

@Zhen-hao no, I can't recall this being a "no-fix" issue :). Parameterless-enums are a bit special (as the cases don't form proper types), so maybe some special-casing needs to be done in the macro. Maybe you'd like to take a stab at trying to fix this?

Good to know that there are no inherent challenges on this issue. I can take a look at it this weekend. No guarantee that I will find a solution.

Zhen-hao commented 1 year ago

I didn't get the time to work on it. Hopefully, I can look into it in October.

adamw commented 1 year ago

@Zhen-hao no worries, looking forward! :)