Uploaded image for project: 'Swift'
  1. Swift
  2. SR-4229

Cannot use mutating member on immutable value: 'self' is immutable

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Duplicate
    • Component/s: Compiler
    • Labels:
      None

      Description

      Is this error correct? If yes, how to work around it because mutating doesn't work on classes

      protocol Foo {
          mutating func restoreState()
      }
      
      extension Foo {
          mutating func restoreState() {}
      }
      
      class Bar: Foo {
          func foo() {
              restoreState()
          }
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              aciid Ankit Aggarwal
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: