-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[GSB] [Diag] Constraint to concrete type using ":" should offer a fix-it #22152
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
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to keep nit-picking, we're getting close!
@jrose-apple Ah ok, I am thinking about what the best solution would be to handle this scenario. Maybe enforce that the current decl context isn't a protocol (or if it is, then the subject type isn't defined inside the protocol)? Because in this example, the fix-it should be offered: protocol Foo {
func S<T : Sequence>(bar: T) where T.Element: String // fix-it for ==
} but not in this situation: protocol Foo {
func foo<T>(bar: T) -> T where T: String // no fixit
associatedtype Baz: String // no fixit
} |
Right, the fix-it can be offered when
|
@jrose-apple Hmm, the subject type ends up being a dependent type, but checking if it has an associated type decl or not seems to work 🎉 Ran the tests again and I think this is good to go. |
A DependentMemberType having an associated type set does not mean it’s part of an associated type’s inheritance clause. The “real” way to see if you’re inside an extension or not, or an associated type, etc is to look at the RequirementSource passed in when the constraint was added. @DougGregor can you help explain how this works? |
@slavapestov Interesting. At the moment, I have a check It seems we can check for |
@slavapestov I have updated my code to use |
@swift-ci Please test |
Build failed |
Build failed |
All tests have passed @jrose-apple 🎉 |
:-) Still waiting on Slava for final review, but it's looking good to me! |
OK. I still don't completely understand the dependent member type thing, but If source compat passes, I'm happy enough to merge. |
@swift-ci Please test source compatibility |
@slavapestov I have updated the code based on @DougGregor's feedback. Could you run the CI again for me? It's only a minor change so not sure if it requires a full test + source compat again. |
Drive-by CI @swift-ci Please test |
Build failed |
Build failed |
Tests have passed 🎉 @jrose-apple @slavapestov |
Thank you, @theblixguy! |
This PR adds a fix-it when constraining to a concrete type using ":".
Example:
Resolves SR-7984.
Resolves rdar://problem/41069420