Erase existential thrown error types #72194
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When performing a throwing operation on an opened existential, the thrown error type could be dependent on the opened existential type, e.g., if the thrown error type is an associated type of one of the corresponding protocols. In such cases, type-erase the thrown error type at the point where it is thrown so that the opened archetype cannot "escape" the enclosing opened-existential operation via throwing.
There is an alternative approach we could take that has
OpenExistentialExpr
handle the type erasure of the thrown error type. This would makeOpenExistentialExpr
a catch node, which would type-erase and then rethrow. This is arguably better, because it could mean fewer places where we do the type erasure and is more in line with the design of opened archetypes. However, it would also be much more invasive, and we should be able to do this later.Fixes rdar://124273722.