Skip to content

[5.9🍒] Batch of small noncopyable type fixes #65912

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 4 commits into from
May 16, 2023

Conversation

kavon
Copy link
Member

@kavon kavon commented May 15, 2023

Pick of


• Description: Fixes small Sema bug preventing discard statements in generic noncopyable types.
• Risk: Low. Expands the kinds of code permitted by compiler.
• Original PR: #65896 and one commit of #65931
• Reviewed By: @slavapestov, @jckarter
• Testing: tests included
• Resolves: rdar://108975216


• Description: Subscripts today don't support any form of ownership specifier for its parameters. Since noncopyable types require such a specifier, it's not helpful to emit an error suggesting to add the specifier. Instead, just say that noncopyable types can't be parameters of a subscript.
• Risk: Low. replaces one error diagnostic with a different one that has no fix-it.
• Original PR: #65898
• Reviewed By: @jckarter
• Testing: tests included
• Resolves: rdar://109233314


• Description: Prevent discard `self` from being permitted
• Risk: Low. I doubt anybody was skirting around the discard self restriction with let `self` = x
• Original PR: one commit of #65931
• Reviewed By: @jckarter
• Testing: tests included
• Resolves: rdar://109376381

kavon added 4 commits May 14, 2023 18:37
A bug was preventing you from writing `discard self`
in a consuming method of a generic noncopyable type.

The main cause was the `isPureMoveOnly` ignored
unbound generic types, claiming none of them are
noncopyable. Then I also needed to pass the contextual
type with the vars bound to the type checker.

rdar://108975216
(cherry picked from commit 20b060b)
Subscripts today don't support any form of ownership specifier
for its parameters Since noncopyable types require such a
specifier, it's not helpful to emit an error suggesting to add
the specifier.

rdar://109233314
(cherry picked from commit 3ce8244)
Don't use `getDeclaredTypeInContext` it gives
the wrong types for generic params.

rdar://108975216
(cherry picked from commit da9847a)
previous checking for the expr being `self`
was checking for the decl being named `self`.

that meant you could do naughty things like:

```
let `self` = Self()
discard `self`
```

rdar://109376381
(cherry picked from commit 1c9ed33)
@kavon kavon marked this pull request as ready for review May 16, 2023 04:18
@kavon kavon requested a review from a team as a code owner May 16, 2023 04:18
@kavon
Copy link
Member Author

kavon commented May 16, 2023

@swift-ci please test

@kavon kavon requested review from jckarter and gottesmm May 16, 2023 04:33
@kavon kavon merged commit 34684c1 into swiftlang:release/5.9 May 16, 2023
@kavon kavon deleted the 5.9-noncopyable-fixes branch May 17, 2023 00:07
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.

3 participants