Skip to content

[4.1] Validate class constraints for generic arguments of types #14178

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

DougGregor
Copy link
Member

Explanation: AnyObject constraints on type parameters of generic types weren't getting checked, allowing invalid types to be formed.
Scope of Issue: Allows ill-formed code to propagate beyond the type checker, causing crashes down the line. Such code was rejected prior to Swift 4.0.
Origination: The removal of AnyObject as a magical protocol left this hole.
Risk: Low risk; we're checking a constraint consistently now. Any source code that breaks due to this was ill-formed and would likely have crashed later on anyway.
Reviewed By: @rudkx
Testing: Compiler regression tests, including new tests.
Radar / SR: SR-6841 / rdar://problem/36884025

…pes.

Class constraints (spelled T: AnyObject) on generic types were not
getting checked on generic arguments. This appears to be a regression
introduced in Swift 4.0 with the removal of AnyObject, leading to a
fairly significant soundness hole that could produce crashers later
on.

Fixes SR-6841 / rdar://problem/36884025.

(cherry picked from commit ee99c8a)
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

@swift-ci please nominate

@DougGregor DougGregor merged commit 895070c into swiftlang:swift-4.1-branch Jan 26, 2018
@DougGregor DougGregor deleted the class-constraints-4.1 branch January 26, 2018 05:53
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