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

Missing fix-it to add 'override' keyword while trying to override a computed property

    XMLWordPrintable

    Details

      Description

      Consider following example:

      class A {
        var a: Int {
          return 42
        }
      
        func b() -> Int { return 42 }
      }
      
      class B: A {
        var a: Int { return 0 }
      
        func b() -> Int {
          return 0
        }
      }
      

      It produces following errors:

      error: overriding declaration requires an 'override' keyword
          var a: Int { return 0 }
              ^
      note: overridden declaration is here
          var a: Int {
              ^
      error: overriding declaration requires an 'override' keyword
          func b() -> Int {
         ^
          override
      note: overridden declaration is here
          func b() -> Int { return 42 }
               ^
      

      But as you can see there is only one 'override' fix-it suggested - for `func b`.

        Attachments

          Activity

            People

            Assignee:
            phillfarrugia Phill Farrugia
            Reporter:
            xedin Pavel Yaskevich
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: