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

Provide some way to call a protocol's base's overload of a method.

    XMLWordPrintable

    Details

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

      Description

      Sometimes, a protocol provides an overload of a super-protocol's method. Since it's an extension method, which one you get depends on what kind of reference you have to the receiver.

      For example, the split methods used to be requirements on Sequence. Now they have moved to be extensions. These methods also exist on Collection. If you have a collection, you always get Collection.split when you call split. The only way to call the Sequence version is to wrap the object within AnySequence. You can also add an extension method to Sequence with a custom name to call Sequence.split.

      But the above solution is not scaleable. You have to keep coming up with unique names and hope someone doesn't add an overload to the refined protocol. I think C++ has ways for an object to call the base type version of an overloaded method, and we should similarly add a general way to do this in Swift.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                CTMacUser Daryle Walker
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: