Skip to content
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-10775] Mutating method in protocol extension always requires variable to be var #53165

Closed
swift-ci opened this issue May 26, 2019 · 0 comments
Labels

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented May 26, 2019

Previous ID SR-10775
Radar None
Original Reporter fumoboy007 (JIRA User)
Type Bug
Status Closed
Resolution Duplicate

Attachment: Download

Environment

Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)
Target: x86_64-apple-darwin18.6.0

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: ab0a323b49b55ccc543bf96676de562c

duplicates:

  • SR-142 mutating function in protocol extension erroneously requires var declaration of class variables

Issue Description:

Consider the following code:

protocol ProtocolWithMutableMethod {
   mutating func mutateStuff()
}

extension ProtocolWithMutableMethod {
   mutating func mutateStuff() {
   }
}

struct MyClass: ProtocolWithMutableMethod {
}

let object = MyClass()
object.mutateStuff()

The compiler complains “Cannot use mutating member on immutable value: 'object' is a 'let’ constant” even though object is clearly a reference type where everything is mutable.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant