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

Concrete same-type requirements

    XMLWordPrintable

    Details

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

      Description

      From the Generics Manifesto:

      Currently, a constrained extension cannot use a same-type constraint to make a type parameter equivalent to a concrete type. For example:

      extension Array where Element == String {
        func makeSentence() -> String {
          // uppercase first string, concatenate with spaces, add a period, whatever
        }
      }
      

      This is a highly-requested feature that fits into the existing syntax and semantics. Note that one could imagine introducing new syntax, e.g., extending Array<String>, which gets into new-feature territory: see the section on "Parameterized extensions".

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              hartbit David Hart
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: