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

Swift/ObjC selector matching is flawed when protocol conformance is declared in superclass

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:
      None
    • Environment:

      Noticed in Xcode Version 8.2.1 (8C1002), reproduces in Xcode Version 8.3 beta 2 (8W120l).

      macOS Sierra 10.12.3 (16D32)

      Description

      Summary:
      The Swift compiler (rightfully) complains about selector mismatches of optional protocol methods when the protocol conformance is declared on that class directly, but the error is missing if the protocol conformance is inherited.

      Steps to Reproduce:
      Please open and run the sample app.

      Note that `tableView(:editingStyleForRowAtIndexPath:)` (SubController.swift) has not been migrated correctly, as the second parameter has not been stripped of `IndexPath`.

      Strangely enough, you can set a breakpoint and will note that this method is called at runtime.

      If you remove the UITableViewDelegate conformance declaration from BaseController.swift and declare it within SubController.swift directly, the compiler shows an error + FixIt as expected.

      Expected Results:
      The compiler should show the error regardless where the protocol conformance has been declared.

      Actual Results:
      The compiler shows certain warnings only when protocol conformance is declared on that class directly.

      Notes:
      This is a follow-up of rdar://27348369 that has been resolved (from my point of view), but seems very similar in nature.

        Attachments

          Activity

            People

            • Assignee:
              DougGregor Doug Gregor
              Reporter:
              hagi Sebastian Hagedorn
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: