Skip to content

Minor updates for LibraryEvolution.rst #20135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2018

Conversation

slavapestov
Copy link
Contributor

  • We don't allow local typealiases in inlinable code either.
  • Explicitly document the places where adding or removing 'lazy'
    is allowed and not allowed (it's effectively like going between
    stored and computed).
  • Adding associated types with defaults is now allowed.
  • For non-@objc enums, adding a raw type is OK -- it's just a
    compiler-synthesized RawRepresentable conformance and is not
    used for layout.
  • Adding/removing/re-ordering extension members does not
    follow the rules of the type itself.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

- Removing a non-public case is not applicable.
- Adding a raw type is still permitted.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps @DougGregor or @jckarter knows if adding a raw type has any effects in addition to what you'd get if you wrote the conformance manually?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like I remember some from SE-0192 but perhaps I didn't actually implement them. (I know at one point we tossed around the idea of raw type = trivial one-word or 64-bit representation.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A raw type is just sugar for implementing a RawRepresentable conformance. It doesn't change the representation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.

@@ -827,6 +839,7 @@ There are very few safe changes to make to protocols and their members:

- A new non-type requirement may be added to a protocol, as long as it has an
unconstrained default implementation.
- A new associated type requirement may be added as long as it has a default.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this until we have a generalized existential story.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. This is true for adding new requirements with non-covariant Self, too. I'll add a separate bullet explaining that making something not usable as an existential is binary-compatible but not source-compatible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Even if you already had associated types, I think we should be able to support the "existential of fully-constrained subprotocol" possibly before we get the full generalized existentials. It's a much easier change to reason about, and this would break that too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a radar on me for that :) One day...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amusing thing about binary compatibility: as? P casts written before P gained an associated type will continue to work fine, but the source code, if recompiled, would result in a compiler error.

- Removing any non-public, non-versioned member.
- Changing the body of any methods, initializers, or accessors.

Additionally, non-protocol extensions have a handful of additional rules:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"allow a few additional changes"? (since the items are all positive noun phrases)

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

1 similar comment
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@@ -840,9 +853,18 @@ There are very few safe changes to make to protocols and their members:
be added to a function requirement without any additional versioning
information.

Note that clients can use a protocol as an existential type as long as it does
not have any associated types or requirements containing ``Self`` in
non-contravariant position. Therefore adding such a requirement becomes a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You double-negated this, yeah? "non-covariant" or "contravariant".


Adding such requirements to protocols that already contain such requirements and
cannot be used as existential types, on the other hand, is always
source-compatible.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the thing I don't want to promise, because of fully-constrained sub-protocols.

All other changes to the protocol itself are forbidden, including:

- Adding a new associated type.
- Adding or removing refined protocols.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh, good catch.

- We don't allow local typealiases in inlinable code either.
- Explicitly document the places where adding or removing 'lazy'
  is allowed and not allowed (it's effectively like going between
  stored and computed).
- Adding associated types with defaults is now allowed.
- Adding associated types or Self requirements to a protocol that
  did not already have them is a *binary-compatible source-breaking
  change*.
- For non-@objc enums, adding a raw type is OK -- it's just a
  compiler-synthesized RawRepresentable conformance and is not
  used for layout.
- Adding/removing/re-ordering extension members does _not_
  follow the rules of the type itself.
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

1 similar comment
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test macOS

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov merged commit 80419c7 into swiftlang:master Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants