Skip to content

AST: Fix ProtocolDecl::getInheritedProtocols() for protocols that inherit from compositions [4.0] #10354

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

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Jun 17, 2017

  • Description: Fix a name lookup bug in a multi-file scenario where a protocol defined in another source file inherits from a typealias containing a protocol composition. Manifests as an assertion failure in Sema when asserts are on, and a SILGen crash when asserts are off.

  • Origination: Recent regression introduced by the associated type where clause work.

  • Risk: Low, the modified code should behave identically except when a protocol composition type appears in the inheritance clause.

  • Tested: Added a reduced test case from a user project that encountered the bug.

  • Reviewed by: @DougGregor

  • Radar: rdar://problem/32595988

…erit from compositions

We allow protocols to inherit from protocol compositions
defined via a typealias, eg,

typealias PQ = P & Q

protocol R : PQ {}

Sometimes, ProtocolDecl::getInheritedProtocols() is called before
the protocol's requirement signature has been computed. In this
case, we walk the inheritance clause of the protocol directly.
This walk was only looking at ProtocolType members of the
inheritance clause, ignoring ProtocolCompositionTypes.

As a result, name lookup could fail with an assertion because of
not being able to "see" members inherited via the protocol
composition.

Fixes <rdar://problem/32595988>.
@slavapestov
Copy link
Contributor Author

@DougGregor Do you mind reviewing this for 4.0?

@slavapestov slavapestov changed the title AST: Fix ProtocolDecl::getInheritedProtocols() for protocols that inherit from compositions AST: Fix ProtocolDecl::getInheritedProtocols() for protocols that inherit from compositions [4.0] Jun 17, 2017
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@najacque
Copy link
Contributor

@swift-ci please clean test

@DougGregor
Copy link
Member

LGTM.

@tkremenek tkremenek merged commit 34a4223 into swiftlang:swift-4.0-branch Jun 19, 2017
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