Skip to content

[Sema] Check protocol conformance availability for member reference and type erasing expressions #41054

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

tshortli
Copy link
Contributor

@tshortli tshortli commented Jan 28, 2022

Diagnose uses of potentially unavailable protocol conformances in member reference expressions (x.foo where foo is a property of x) and type erasure expressions (let p: P = S where S conforms to P) since unguarded uses of these conformances can cause crashes at runtime.

Expands conformance availability tests to include test cases covering member references, key paths, and invocation of functions taking existentials.

Resolves rdar://87795154 and rdar://83731428.

…rovided by a protocol conformance be sure to check the availability of conformance.

Expands conformance availability tests to include test cases covering member references and key paths.

Resolves rdar://87795154.
@tshortli tshortli requested a review from slavapestov January 28, 2022 04:46
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

Nice catch! IIRC there is another missing case with ErasureExpr that occurs when forming an existential from a concrete type, if the concrete type's conformance to the protocol is not available.

@tshortli
Copy link
Contributor Author

Nice catch! IIRC there is another missing case with ErasureExpr that occurs when forming an existential from a concrete type, if the concrete type's conformance to the protocol is not available.

Thanks! I'll see what it would take to expand this to cover that expression as well.

@slavapestov
Copy link
Contributor

@tshortli here is @beccadax's radar for that one by the way: rdar://83731428

…ons (e.g. `let x: P = S` where S conforms to P).

Resolves rdar://83731428.
@tshortli tshortli changed the title [Sema] Check protocol conformance availability for member references [Sema] Check protocol conformance availability for member reference and type erasing expressions Jan 28, 2022
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

@tshortli tshortli force-pushed the check-protocol-conformance-availability-for-members branch from 2040377 to d575bba Compare January 29, 2022 00:12
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

@tshortli
Copy link
Contributor Author

@swift-ci please test macOS

@tshortli
Copy link
Contributor Author

@swift-ci please smoke test macOS

@tshortli tshortli merged commit edf98aa into swiftlang:main Feb 1, 2022
@tshortli tshortli deleted the check-protocol-conformance-availability-for-members branch February 8, 2022 07:33
beccadax pushed a commit to beccadax/swift that referenced this pull request Apr 21, 2022
In swiftlang#41054, we fixed an oversight which caused us to not notice when a user erased a concrete type to an existential using an unavailable conformance. Unfortunately, this is source-breaking and needs to be reduced to a warning in Swift 5 mode unless the user opts in.

Fixes rdar://91940820.
beccadax pushed a commit to beccadax/swift that referenced this pull request Apr 21, 2022
In swiftlang#41054, we fixed an oversight which caused us to not notice when a user erased a concrete type to an existential using an unavailable conformance. Unfortunately, this is source-breaking and needs to be reduced to a warning in Swift 5 mode unless the user opts in.

Fixes rdar://91940820.
beccadax pushed a commit to beccadax/swift that referenced this pull request Apr 22, 2022
In swiftlang#41054, we fixed an oversight which caused us to not notice when a user erased a concrete type to an existential using an unavailable conformance. Unfortunately, this is source-breaking and needs to be reduced to a warning in Swift 5 mode unless the user opts in.

Fixes rdar://91940820.
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.

2 participants