Skip to content

[AST] Bring 'mutating' and 'inout self' in sync. #10375

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 1 commit into from
Jun 19, 2017

Conversation

jrose-apple
Copy link
Contributor

  • A mutating method or accessor always has inout self.
  • A nonmutating method or accessor never has inout self.
  • Only instance members can be mutating.

Came up after reviewing another patch that confused the two as possibly distinct concepts.

@jrose-apple
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor

LGTM, thanks for adding the new verifier check too!

- A mutating method or accessor always has 'inout self'.
- A nonmutating method or accessor never has 'inout self'.
- Only instance members can be mutating.
- Addressors are still addressors even when on static members.

Came up after reviewing another patch that confused the two as
possibly distinct concepts.
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - 1f8ee15a0836052ba7f1437e8ef107a011255156
Test requested by - @jrose-apple

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - 1f8ee15a0836052ba7f1437e8ef107a011255156
Test requested by - @jrose-apple

@@ -188,12 +188,16 @@ struct S: Fooable {
// CHECK-NOT: destroy_addr [[SELF_ADDR]]

// Witness thunk for prop3 nonmutating materializeForSet
// CHECK-LABEL: sil private [transparent] [thunk] @_T015guaranteed_self1SVAA7FooableA2aDP5prop3SifmTW : $@convention(witness_method) (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @inout S) -> (Builtin.RawPointer, Optional<Builtin.RawPointer>)
// CHECK-LABEL: sil private [transparent] [thunk] @_T015guaranteed_self1SVAA7FooableA2aDP5prop3SifmTW : $@convention(witness_method) (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @in_guaranteed S) -> (Builtin.RawPointer, Optional<Builtin.RawPointer>)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slavapestov Additional sanity check that this change is reasonable? It certainly seems desirable, but I don't want it to break something at the other end of the compiler.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense.

@jrose-apple jrose-apple merged commit 77de3dc into swiftlang:master Jun 19, 2017
@jrose-apple jrose-apple deleted the mutating branch June 19, 2017 23:16
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