-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix objcImpl bug causing invalid @_hasStorage
attributes in module interfaces
#80360
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A bug in `@objc @implementation` is causing incorrect `@_hasStorage` attributes to be printed into module interfaces. As an initial step towards fixing this, diagnose bad `@_hasStorage` attributes and treat them as computed properties so that these malformed interfaces don’t cause compiler crashes. Partially fixes rdar://144811653.
If an `@objc implementation extension` had a public stored property with an observer, Swift would print `@_hasStorage` on the extension. This is Not Good because in a module interface, an objcImpl extension appears to be an ordinary extension, and properties in ordinary extensions are not supposed to have storage. Suppress printing this attribute in objcImpl extensions to avoid this problem. Partially fixes rdar://144811653 by suppressing emission of bad attributes.
An objcImpl bug previously caused `@_hasStorage` to be emitted inside some extensions in module interfaces. An earlier commit in this PR created an error for this, but for backwards compatibility, it would actually be better to simply ignore the attribute in module interfaces. Modify TypeCheckStorage to emit a warning, not an error, in this situation. Additionally, modify the module interface loader to show warnings when you verify a module interface, but not for other module interface uses (like compiling or importing one). The assumption here is that if you’re verifying a module interface, you’re either the author of the module that created it or you’re investigating a problem with it, and in either case you’d like to be told about minor defects in case they’re related. Fixes rdar://144811653 thoroughly.
@swift-ci please test |
@swift-ci please smoke test Windows platform |
nkcsgexi
approved these changes
Mar 28, 2025
tshortli
added a commit
to tshortli/swift
that referenced
this pull request
Mar 31, 2025
…king. We're not ready to start emitting warnings when typechecking modules from interface. It is causing performance regressions and spurious diagnostics to be emitted. Reverts a small part of swiftlang#80360. Resolves rdar://148257136.
tshortli
added a commit
to tshortli/swift
that referenced
this pull request
Mar 31, 2025
…cking. We're not ready to start emitting warnings when typechecking modules from interface. It is causing performance regressions and spurious diagnostics to be emitted. Reverts a small part of swiftlang#80360. Resolves rdar://148257136.
tshortli
added a commit
to tshortli/swift
that referenced
this pull request
Mar 31, 2025
…cking. We're not ready to start emitting warnings when type-checking modules from interface. It is causing performance regressions and spurious diagnostics to be emitted. Reverts a small part of swiftlang#80360. Resolves rdar://148257136.
tshortli
added a commit
to tshortli/swift
that referenced
this pull request
Mar 31, 2025
…cking. We're not ready to start emitting warnings when type-checking modules from interface. It is causing performance regressions and spurious diagnostics to be emitted. Reverts a small part of swiftlang#80360. Resolves rdar://148257136.
tshortli
added a commit
to tshortli/swift
that referenced
this pull request
Apr 1, 2025
…cking. We're not ready to start emitting warnings when type-checking modules from interface. It is causing performance regressions and spurious diagnostics to be emitted. Reverts a small part of swiftlang#80360. Resolves rdar://148257136.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Consider this code:
Because the
var
ispublic final
, it needs to be printed into the module interface as part of an ordinary (non-objcImpl) extension. However, because thedidSet
observer is present, Swift would print a@_hasStorage
attribute:This is bad, of course, because stored properties are not allowed in ordinary extensions. But it's worse than that: because
@_hasStorage
is not particularly well validated, the compiler would not emit a diagnostic about this problem—it would simply crash. Often at a fairly arbitrary point if asserts were disabled.This PR fixes this bug from basically all possible angles:
@_hasStorage
in invalid contexts.@_hasStorage
forvar
s in module interfaces.@_hasStorage
attributes in existing module interfaces.Fixes rdar://144811653.