Old thread resurrection time... I have a client who has a large number of Enums defined, and it would be really handy for them if our enum serializers were type-aware. Now that Lift is done with supporting Scala 2.10, I thought I'd take a preliminary peek under the covers of our code to get something working.
As pointed out in
this thread, part of the problem is that via reflection we record Enumeration.Value in the TypeInfo object when we encounter enums. This doesn't contain enough type information to know
which enum is in question. Furthermore, I also found
this blog post seems to have all anyone needs to figure this one out.
I'm struggling to see a path forward to support this better enum serializer we want without breaking existing API and/or behavior. Ideally we would just need to change the two enum serializers, but we have to change our reflection code to record the surrounding type some how (i.e. the object or whatever which extends Enumeration and defines the Values). Here are the options I've thought so far:
1) Instead of recording the Value type, record the surrounding type. This would preserve our APIs as is, but anyone's code which has been written to expect an Enumeration.Value to workaround our enum limitations would be broken at run time.
2) Add another parameter (probably the TypeTag) to TypeInfo case class. This would break all over the place, but it would be a compile-time failure.
3) Hijack the existing parameterizedType field in TypeInfo to contain the Enumeration.Value's surrounding type. This could still break existing code if folks expect this field to be None. I suspect there other assumptions that would likely be broken by this approach based on what I've seen in the code. So while this one seems to do the least damage on the surface, I think having this special case behavior for enums would cause us greater grief down the line.
I'm going to see if I can get a POC of the first one or two ideas to see what else I learn.
I'd love any thoughts or feedback.
Joe