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

Using "final" keyword in protocol extension doesn't prevent overriding

    XMLWordPrintable

    Details

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

      Description

      If I implement a protocol method in a protocol extension, and mark it as final, it seems that I am able to always override it. Should the compiler allow this?

      import UIKit
      
      var str = "Hello, playground"
      
      protocol P : class {
          func f()
      }
      
      extension P {
          final func f() {} // final has no effect
      }
      
      class A : P {}
      
      class B : A {
          func f() {}
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              KingOfBrian Brian
              Reporter:
              devioustree Tom Drummond
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: