@@ -395,7 +395,7 @@ polar representation::
395
395
and the ``x `` and ``y `` properties have now disappeared. To avoid this, the
396
396
bodies of inlinable functions have the following restrictions:
397
397
398
- - They may not define any local types (other than typealiases) .
398
+ - They may not define any local types.
399
399
400
400
- They must not reference any ``private `` or ``fileprivate `` entities.
401
401
@@ -415,12 +415,12 @@ Default argument expressions for functions that are public, versioned, or
415
415
inlinable are implemented very similar to inlinable functions and thus are
416
416
subject to similar restrictions:
417
417
418
- - They may not define any local types (other than typealiases) .
418
+ - They may not define any local types.
419
419
420
420
- They must not reference any non-``public `` entities.
421
421
422
422
- They must not reference any entities from the current module introduced
423
- after the function was made inlinable , except under appropriate availability
423
+ after the default argument was added , except under appropriate availability
424
424
guards.
425
425
426
426
A default argument implicitly has the same availability as the function it is
@@ -438,6 +438,8 @@ changes are permitted:
438
438
- Adding or removing a non-public, non-versioned setter.
439
439
- Changing from a stored variable to a computed variable, or vice versa, as
440
440
long as a previously versioned setter is not removed.
441
+ - As a special case of the above, adding or removing ``lazy `` from a stored
442
+ property.
441
443
- Changing the body of an accessor.
442
444
- Adding or removing an observing accessor (``willSet `` or ``didSet ``) to/from
443
445
an existing variable. This is effectively the same as modifying the body of a
@@ -482,6 +484,7 @@ amount:
482
484
- Adding or removing a non-public, non-versioned setter is still permitted.
483
485
- Changing from stored to computed or vice versa is forbidden, because it would
484
486
break existing clients.
487
+ - Similarly, adding or removing ``lazy `` is forbidden.
485
488
- Changing the body of an accessor is a `binary-compatible source-breaking
486
489
change `.
487
490
- Adding/removing observing accessors is likewise a `binary-compatible
@@ -530,6 +533,8 @@ the following changes are permitted:
530
533
- Reordering any existing members, including stored properties.
531
534
- Adding any new members, including stored properties.
532
535
- Changing existing properties from stored to computed or vice versa.
536
+ - As a special case of the above, adding or removing ``lazy `` from a stored
537
+ property.
533
538
- Changing the body of any methods, initializers, or accessors.
534
539
- Adding or removing an observing accessor (``willSet `` or ``didSet ``) to/from
535
540
an existing property. This is effectively the same as modifying the body of a
@@ -651,8 +656,10 @@ properties in a ``@fixedContents`` struct are implicitly declared
651
656
Reordering all other members is still permitted.
652
657
- Adding new stored instance properties (public or non-public) is not permitted.
653
658
Adding any other new members is still permitted.
654
- - Existing instance properties may not be changed from stored to computed or
655
- vice versa.
659
+ - Changing existing instance properties from stored to computed or
660
+ vice versa is not permitted.
661
+ - Similarly, adding or removing ``lazy `` from a stored property is not
662
+ permitted.
656
663
- Changing the body of any *existing * methods, initializers, computed property
657
664
accessors, or non-instance stored property accessors is permitted. Changing
658
665
the body of a stored instance property observing accessor is permitted if the
@@ -670,6 +677,12 @@ Additionally, if the type of any stored instance property includes a struct or
670
677
enum, that struct or enum must be `versioned <versioned entity> `. This includes
671
678
generic parameters and members of tuples.
672
679
680
+ .. note ::
681
+
682
+ The above restrictions do not apply to ``static `` properties of
683
+ ``@fixedContents `` structs. Static members effectively behave as top-level
684
+ functions and variables.
685
+
673
686
.. note ::
674
687
675
688
The name ``@fixedContents `` is intentionally awful to encourage us to come
@@ -787,9 +800,8 @@ clients that the enum cases are exhaustive. In particular:
787
800
788
801
- Adding new cases is not permitted.
789
802
- Reordering existing cases is not permitted.
790
- - Adding a raw type to an enum that does not have one is not permitted -- it's
791
- used for optimization.
792
803
- Removing a non-public case is not applicable.
804
+ - Adding a raw type is still permitted.
793
805
- Adding any other members is still permitted.
794
806
- Removing any non-public, non-versioned members is still permitted.
795
807
- Adding a new protocol conformance is still permitted.
@@ -827,6 +839,7 @@ There are very few safe changes to make to protocols and their members:
827
839
828
840
- A new non-type requirement may be added to a protocol, as long as it has an
829
841
unconstrained default implementation.
842
+ - A new associated type requirement may be added as long as it has a default.
830
843
- A default may be added to an associated type.
831
844
- Removing a default from an associated type is a `binary-compatible
832
845
source-breaking change `.
@@ -840,9 +853,18 @@ There are very few safe changes to make to protocols and their members:
840
853
be added to a function requirement without any additional versioning
841
854
information.
842
855
856
+ Note that clients can use a protocol as an existential type as long as it does
857
+ not have any associated types or requirements containing ``Self `` in
858
+ non-covariant position. Therefore adding such a requirement becomes a
859
+ `binary-compatible source-breaking change `.
860
+
861
+ Adding such requirements to protocols that already contain such requirements and
862
+ cannot be used as existential types, on the other hand, is always
863
+ source-compatible.
864
+
843
865
All other changes to the protocol itself are forbidden, including:
844
866
845
- - Adding a new associated type .
867
+ - Adding or removing refined protocols .
846
868
- Removing any existing requirements (type or non-type).
847
869
- Making an existing requirement optional.
848
870
- Making a non-``@objc `` protocol ``@objc `` or vice versa.
@@ -874,6 +896,8 @@ support all of the following changes:
874
896
875
897
- Reordering any existing members, including stored properties.
876
898
- Changing existing properties from stored to computed or vice versa.
899
+ - As a special case of the above, adding or removing ``lazy `` from a stored
900
+ property.
877
901
- Changing the body of any methods, initializers, or accessors.
878
902
- Adding or removing an observing accessor (``willSet `` or ``didSet ``) to/from
879
903
an existing property. This is effectively the same as modifying the body of a
@@ -1090,13 +1114,20 @@ additive feature, it can be added to the model at any time.
1090
1114
Extensions
1091
1115
~~~~~~~~~~
1092
1116
1093
- Non-protocol extensions largely follow the same rules as the types they extend.
1117
+ Extensions largely follow the same rules as the types they extend.
1094
1118
The following changes are permitted:
1095
1119
1096
1120
- Adding new extensions and removing empty extensions (that is, extensions that
1097
1121
declare neither members nor protocol conformances).
1098
1122
- Moving a member from one extension to another within the same module, as long
1099
1123
as both extensions have the exact same constraints.
1124
+ - Adding any new member.
1125
+ - Reordering members.
1126
+ - Removing any non-public, non-versioned member.
1127
+ - Changing the body of any methods, initializers, or accessors.
1128
+
1129
+ Additionally, non-protocol extensions allow a few additional changes:
1130
+
1100
1131
- Moving a member from an unconstrained extension to the declaration of the
1101
1132
base type, provided that the declaration is in the same module. The reverse
1102
1133
is permitted for all members except stored properties, although note that
@@ -1105,24 +1136,6 @@ The following changes are permitted:
1105
1136
- Adding a new protocol conformance (with proper availability annotations).
1106
1137
- Removing conformances to non-public protocols.
1107
1138
1108
- Adding, removing, reordering, and modifying members follow the same rules as
1109
- the base type; see the sections on structs, enums, and classes above.
1110
-
1111
-
1112
- Protocol Extensions
1113
- -------------------
1114
-
1115
- Protocol extensions follow slightly different rules from other extensions; the
1116
- following changes are permitted:
1117
-
1118
- - Adding new extensions and removing empty extensions.
1119
- - Moving a member from one extension to another within the same module, as long
1120
- as both extensions have the exact same constraints.
1121
- - Adding any new member.
1122
- - Reordering members.
1123
- - Removing any non-public, non-versioned member.
1124
- - Changing the body of any methods, initializers, or accessors.
1125
-
1126
1139
.. note ::
1127
1140
1128
1141
Although it is not related to evolution, it is worth noting that members of
0 commit comments