Skip to content

Tighten up unsafe effects checking #78585

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
merged 10 commits into from
Jan 12, 2025

Conversation

DougGregor
Copy link
Member

Improve unsafe effects checking to capture more potential uses of unsafe constructs:

  • References to unsafe declarations in constructors, literal conversions, and key paths
  • References to unsafe conformances in existential conversions, opaque result type conversions
  • References to unsafe types in casts and metatype references
  • References to unsafe conformances in the for..in loop
  • Properly handle unsafe with auto closures

While here, fix some issues with @unsafe conformances: they weren't being recorded as unsafe when placed on an extension (!), and we were inferring that all conformances of an unsafe type are unsafe. We don't need that, because the type being unsafe is enough.

Check for unsafe conformances for type erasure and opaque type
erasure.

This also uncovered an issue where we were making every conformance of
an unsafe type to an unsafe protocol @unsafe implicitly, even though
that's not really what we want.
…larations

Only "unsafe" checking is affected here.
The `unsafe` goes on the sequence expression, e.g.,

    for x in unsafe mySequence { ... }
We track this information via anchor, so we don't need to manage a
separate list that doesn't have an anchor.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor enabled auto-merge January 11, 2025 20:47
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit 78608b3 into swiftlang:main Jan 12, 2025
3 checks passed
@DougGregor DougGregor deleted the more-unsafe-effects-checking branch January 12, 2025 15:58
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