-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ConstraintSystem] Diagnose conditional requirement failures via fixes #22480
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
…quirement locator
Extend existing `RequirementFailure` functionality to support conditional requirement failures. Such fixes are introduced only if the parent type requirement has been matched successfully. Resolves: rdar://problem/47871590
@@ -338,7 +339,7 @@ extension Int: P { } | |||
|
|||
func testConditional(i: Int, s: String) { | |||
let _: PArray<Int> = [i, i, i] | |||
let _: PArray<String> = [s, s, s] // expected-error{{cannot convert value of type '[String]' to specified type 'PArray<String>'}} | |||
let _: PArray<String> = [s, s, s] // expected-error{{generic struct 'PArray' requires that 'String' conform to 'P'}} |
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.
Cool!
If affected declaration is a static or instance memeber (excluding operators) and failed requirement is declared in other nominal type or extension, diagnose such problems as `in reference` instead of claiming that requirement belongs to the member itself.
@swift-ci please test |
Build failed |
@swift-ci please test Linux platform |
Build failed |
Build failed |
@shahmishal Looks like this is something with the bot itself in the final phase. |
@swift-ci please test |
// expected-note@-1 {{candidate requires that the types 'U' and 'V' be equivalent (requirement specified as 'U' == 'V')}} | ||
// expected-note@-2 {{requirement from conditional conformance of 'SameTypeGeneric<U, V>' to 'P2'}} | ||
// expected-note@-3 {{requirement from conditional conformance of 'SubclassBad' to 'P2'}} | ||
// expected-note@-4 {{candidate requires that 'C1' inherit from 'U' (requirement specified as 'U' : 'C1')}} |
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.
Should this read candidate requires that 'U' inherit from 'C1'
?
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.
Yeah, probably, I didn't touch existing messages in declaration checker.
Extend existing
RequirementFailure
functionality to supportconditional requirement failures. Such fixes are introduced
only if the parent type requirement has been matched successfully.
Resolves: rdar://problem/47871590