[SR-4926] Make deserialization recovery more lenient for indirect cases of enums. #47503
Labels
compiler
The Swift compiler in itself
improvement
serialization
Area → compiler: Serialization & deserialization
Additional Detail from JIRA
md5: f769a07dfa816f6c4f9896c6973ef85d
Issue Description:
#9720 made it so that if any case in an enum can't be deserialized, the entire enum can't be deserialized. This is because the layout of enum cases and their payloads affects the layout of the entire enum.
However, there is a special case here (pun intended):
indirect
cases. These have a statically-knowable layout because they are indirect, and therefore can be dropped from the enum's public interface without affecting the other cases. This would entail:Skipping
indirect
cases when collecting "dependency types" for the enum (Serialization.cpp).Adding a field to the serialization format for enum elements to track dependency types (ModuleFormat.h). (This is tricky because the format we're using doesn't allow both a "blob" and an "array". We'll probably need a separate record kind whose only job it is is to hold dependencies.)
Collect dependency types for indirect enum elements. (Don't bother for normal elements.) (Serialization.cpp)
…then copy the dependency-type-checking logic from enums… (Deserialization.cpp)
…but instead of returning an error, just pretend the associated type is Any… (Deserialization.cpp)
…and mark the case unavailable using AvailableAttr. (Deserialization.cpp)
The text was updated successfully, but these errors were encountered: