Skip to content

[Sema] Only require a default implementation for SPI requirements in non-SPI protocols #32793

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 3 commits into from
Jul 15, 2020

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Jul 9, 2020

The check for SPI protocol requirements needing a default implementation should ignore requirements in a protocol that is SPI too. The protocol can’t be conformed to without knowing of the requirement.

rdar://65286171

@xymus
Copy link
Contributor Author

xymus commented Jul 9, 2020

@swift-ci Please smoke test

@xymus xymus force-pushed the spi-req-in-spi-proto branch from 878cc32 to 4f55a02 Compare July 9, 2020 21:09
@xymus
Copy link
Contributor Author

xymus commented Jul 9, 2020

@swift-ci Please smoke test

@xymus xymus requested a review from beccadax July 9, 2020 21:10
@xymus xymus changed the title [Sema] Only require a default requirement on non-SPI protocols [Sema] Only require a default implementation for SPI requirement in non-SPI protocols Jul 9, 2020
@xymus xymus changed the title [Sema] Only require a default implementation for SPI requirement in non-SPI protocols [Sema] Only require a default implementation for SPI requirements in non-SPI protocols Jul 9, 2020
Copy link
Contributor

@beccadax beccadax left a comment

Choose a reason for hiding this comment

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

This change looks good. However, is there a runtime test verifying that test cases like PublicProto work correctly?

extension->isConstrainedExtension())
return false;
if (!protocol->isSPI()) {
auto implementations = TypeChecker::lookupMember(
Copy link
Contributor

Choose a reason for hiding this comment

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

This should reuse the existing logic for finding default implementations instead of rolling its own.

Copy link
Contributor

Choose a reason for hiding this comment

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

More specifically I think these checks could be moved to typechecker::inferDefaultWitnesses().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for pointing this out. I moved the check and it is much cleaner!

xymus added 3 commits July 13, 2020 16:00
Asides from removing duplicated code this change also now checks implicit SPI
requirements and applies only in library evolution mode.
…ntation

The check for SPI protocol requirements needing a default implementation
should ignore requirements in a protocol that is SPI too. The protocol
can’t be conformed to without knowing of the requirement.

rdar://65286171
@xymus xymus force-pushed the spi-req-in-spi-proto branch from 4f55a02 to d70b0c9 Compare July 14, 2020 19:34
@xymus
Copy link
Contributor Author

xymus commented Jul 14, 2020

Moved the check to TypeCheckProtocol with pre-existing logic.

I'll have to spend more time on the runtime test. It works as expected with library evolution but it crashes in an ugly way without it when rebuilding from the public swiftinterface.

@swift-ci Please smoke test

@xymus xymus merged commit 28799e6 into swiftlang:master Jul 15, 2020
@xymus xymus deleted the spi-req-in-spi-proto branch October 31, 2022 21:07
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.

3 participants