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

@available(swift N) to match -swift-version N

    XMLWordPrintable

    Details

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

      Description

      The recently-added -swift-version N flag in SR-2582 only affects the #if swift(>=N) compiler-control statements, which is not sufficient for shipping a library with parts that are unconditionally compiled but conditionally available. For the latter, we need to support something like @available(swift N) similar to the platform availability tests.

      The exact semantics are a bit subtle; as far as I can tell, swift-version unavailability should override platform availability, but swift-version availability should not override platform unavailability. That is, swift-version availability should be considered in conjunction, not disjunction, with platform availability. We don't exactly have a way to write availability conjuncts at the moment, so as an initial implementation we might just prohibit combining `@available(swift N)` with any other platform-availability spec in the same attribute argument list.

      Other suggestions welcome!

        Attachments

          Activity

            People

            Assignee:
            graydon Graydon Hoare
            Reporter:
            graydon Graydon Hoare
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: