Hi Mohammed, The ‘automatic enum value’ code path is used if you have code like this, where you declare a raw type but don’t assign raw values:
enum E : Int { case a case b case c } This only makes sense for a raw type of integer, and not string — or a tuple. Even if you have (Int, Int) as your raw type, it’s not clear how to automatically increment such a value, so I think you shouldn’t be hitting this code path at all if you have a tuple raw type. Slava > On Nov 18, 2017, at 1:07 PM, Mohammed Ennabah via swift-dev > <swift-dev@swift.org> wrote: > > I have been digging into the Swift library to solve the case where enum could > have a RawValue of tuples of literals. So far, I found that in > lib/Sema/TypeCheckDecl.cpp::3020 we do check the enum RawValue if it conforms > to a knownProtocolKind, and if true, we switch over to check whether it’s > ExpressibleByXXLiteral (XX could be String, Integer, etc..). > Now, my questions are: > I need to extend this condition to have a tuple of types that conforms to the > knownProtocolKind, and I’m not quite sure where to start. (Note: It’s better > to make the tuple conforms to a protocol type that is knownProtocolKind, so > the enum can be tuple of tuples.., let me know your thoughts please). > We increment the RawValue if it’s of type Integer. What if the tuple of type > (Int, String), will we need to increment the Int part as well? I think yes, > but I’m asking to listen to your thoughts, too. > > > - Mohammed > _______________________________________________ > swift-dev mailing list > swift-dev@swift.org > https://lists.swift.org/mailman/listinfo/swift-dev
_______________________________________________ swift-dev mailing list swift-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-dev