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

Resilient value type support -- umbrella bug

    XMLWordPrintable

    Details

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

      Description

      The goal here is to make client code resilient to changes in the internal representation of library types. In particular, we want the following changes to be resilient by default:

      • Adding a public or internal stored property to a struct
      • Removing a private or internal stored property from a struct, as long as it is not used from @transparent functions
      • Changing a struct stored property into a computed property, or vice versa
      • Adding a payload or no-payload case to an enum
      • Removing an internal case from an enum (not supported by Sema, but the calling convention changes are independent of that)
      • Adding a public or internal stored property to a class
      • Removing a private or internal stored property from a class, as long as it is not used from @transparent functions
      • Changing a class stored property into a computed property, or vice versa
      • Changing a global variable from a stored to computed or vice versa

      To allow optimization, the @_fixed_layout attribute communicates the intent that the layout of a type is part of the interface and will not change. The layout is defined as follows:

      • For structs, the ordering and types of all stored properties must never change
      • For enums, the total set of all payload and no-payload cases must never change

      Note that @_fixed_layout types can contain resiliently-typed properties or payloads, and have a dynamic size as a result.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              slavapestov Slava Pestov
              Reporter:
              slavapestov Slava Pestov
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: