Skip to content

GSB: Start purging the notion of "derived via concrete" requirements #36811

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

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Apr 8, 2021

The notion of a 'derived via concrete' requirement was meant to handle the following scenario:

protocol P { associatedtype T : P }
class C<T : P> : P
func foo<X, Y>(_: X, _: Y) where X : P, Y : P, X : C<Y> {}

The requirement Y : P is implied by X : P, since X : C<Y> introduces Y == X.T, we have X : P, and T : P in protocol P. Since X : P is in turn implied by X : C<Y>, we would normally consider both X : P and Y : P redundant -- but as soon as we drop X : P, we must keep Y : P, since X : C<Y> by itself does not imply that Y : P. This was captured by saying that Y : P was "derived via (the) concrete" requirement X : C<Y>.

However, the recently-introduced mechanism for rebuilding signatures after dropping redundant conformance requirements subsumes this notion. In the above example, once we drop X : P, we build the signature X : C<Y>, Y : P. The only thing we have to change is that when rebuilding a signature, instead of dropping all redundant requirements (which would also drop Y : P) we only drop those that are directly implied by a superclass or concrete type requirement. X : P is directly implied by X : C<Y>, but Y : P is derived from X : P.

Since rebuilding doesn't yet work for requirement signatures, we can't remove it outright, but we can narrow it down to only occur with a requirement signature. Once we can rebuild requirement signatures, we can remove this logic entirely.

…lding requirement signatures

Once we can rebuild requirement signatures after dropping redundant
requirements, we won't need this at all.
@slavapestov slavapestov force-pushed the start-purging-derived-via-concrete branch from 1fb71bb to e8c4418 Compare April 8, 2021 05:25
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov merged commit 368b387 into swiftlang:main Apr 8, 2021
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.

1 participant