Closed ilyapuchka closed 7 years ago
Seems like a sensible approach, in 2.a.iii let's do manual scan instead of failing since it's pretty straightforward, you can take a look at how I access src code in the Associated values for enums since that's not provided by.
Currently enums assume that the first type after
:
is a rawValue type. But that will fail in a couple of scenarios. There are several different ways to define valid enum:RawRepresentable
:I can suggest the following logic:
RawRepresentable
at any position in inherited types: 2.a.i check type of rawValue property, or 2.a.ii check type of rawValue constructor argument, or 2.a.iii fail otherwise (as SourceKitten does not provide info about typealiases) or scan type body content fortypealias
2.b if there is noRawReperesentable
in inherited types get the first type as rawValue type if there is anyThere are of course more scenarios that will still not work (like enum that implements protocol derived from RawRepresentable), but we can always improve in the future.