Skip to content

Erase existential thrown error types #72194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

DougGregor
Copy link
Member

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 make OpenExistentialExpr 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.

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 make `OpenExistentialExpr` 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.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor enabled auto-merge March 8, 2024 19:51
@DougGregor DougGregor merged commit 523f807 into swiftlang:main Mar 8, 2024
@DougGregor DougGregor deleted the thrown-error-opened-archetypes branch March 8, 2024 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant