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
[SR-11128] Protocol stubs include __consuming and __owned #53524
Comments
In later work on my project, I realized that |
Can you file a separate bug for "mutating implementations should satisfy consuming requirements"? I think there's a Radar for the protocol stubs one, too. |
We talked and we don't actually think |
Just to clarify, do we always want to drop __consuming and __owned when printing stubs or only when the type is not move-only? Also, since only functions can have the __consuming attribute (correct me if I am wrong), should we add a check before printing it? |
We don't have any such thing as "move-only types" yet. And I think you meant "only structs and enums" rather than "only functions", right? |
I meant functions, because if you add **consuming ** to anything other than a func then the compiler throws an error: "__consuming may only be used on 'func' declarations" (unless I am doing something wrong!). To fix this, I was thinking of setting SkipUnderscoredKeywords=true in printRequirementStub(). |
The point of protocol stubs is to match what was written in a protocol's requirements, though. If someone put __consuming on a non-function in a protocol, they already would have gotten an error. |
Environment
Reproduced in Xcode 11 beta 3 and Swift Development Snapshot 2019-07-11 (a)
Additional Detail from JIRA
md5: b4e61ffcb5ec292d8f0f34fef152663e
Issue Description:
When Swift offers to apply protocol stubs in Xcode, the fix-it produced may include the
__consuming
and__owned
modifiers, which are not currently a supported part of the language and are not intended to be used in most conformances even once they are officially added.Steps To Reproduce:
Although this is a compiler bug, the printed form of compiler diagnostics doesn't display fix-its in sufficient detail to easily demonstrate it. It's most easily reproduced in an Xcode with an appropriate toolchain:
1. Create a new Xcode project with this code in a Swift source file:
2. Build it.
3. Click the error badge on the extension line, then click the “Fix” button to apply the fix-it.
Results:
Some of the stubbed declarations include
__consuming
and/or__owned
modifiers, such as:I would not expect Swift to suggest these modifiers, since they aren’t officially part of the language. Instead I would expect it to drop these keywords:
Even after we fully support move-only types, I would expect the protocol stubs for a non-move-only conformance to remove unnecessary move-only–related modifiers so that users don't need to worry about this complexity.
The text was updated successfully, but these errors were encountered: