-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[TypeChecker] Improve contextual mismatch diagnostics for key path #24308
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,16 +125,16 @@ func testKeyPath(sub: Sub, optSub: OptSub, | |
let _: PartialKeyPath<A> = \.property | ||
let _: KeyPath<A, Prop> = \.property | ||
let _: WritableKeyPath<A, Prop> = \.property | ||
// expected-error@+1{{ambiguous}} (need to improve diagnostic) | ||
let _: ReferenceWritableKeyPath<A, Prop> = \.property | ||
//expected-error@-1 {{cannot convert value of type 'WritableKeyPath<A, Prop>' to specified type 'ReferenceWritableKeyPath<A, Prop>'}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of this test file puts the assertions on the same line or the line before; I think putting these on the line after might confuse future maintainers. (This applies to the other changes in this file, too.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's going to be a big problem especially considering that most of the tests (if not all) have expected checks on the same or line after the one checked. These TODOs where more of an exception to the rule. |
||
|
||
// FIXME: shouldn't be ambiguous | ||
// expected-error@+1{{ambiguous}} | ||
let _: PartialKeyPath<A> = \.[sub] | ||
let _: KeyPath<A, A> = \.[sub] | ||
let _: WritableKeyPath<A, A> = \.[sub] | ||
// expected-error@+1{{ambiguous}} (need to improve diagnostic) | ||
let _: ReferenceWritableKeyPath<A, A> = \.[sub] | ||
// expected-error@-1 {{cannot convert value of type 'WritableKeyPath<A, A>' to specified type 'ReferenceWritableKeyPath<A, A>}} | ||
|
||
let _: PartialKeyPath<A> = \.optProperty? | ||
let _: KeyPath<A, Prop?> = \.optProperty? | ||
|
@@ -158,8 +158,8 @@ func testKeyPath(sub: Sub, optSub: OptSub, | |
let _: PartialKeyPath<C<A>> = \.value | ||
let _: KeyPath<C<A>, A> = \.value | ||
let _: WritableKeyPath<C<A>, A> = \.value | ||
// expected-error@+1{{ambiguous}} (need to improve diagnostic) | ||
let _: ReferenceWritableKeyPath<C<A>, A> = \.value | ||
// expected-error@-1 {{cannot convert value of type 'WritableKeyPath<C<A>, A>' to specified type 'ReferenceWritableKeyPath<C<A>, A>'}} | ||
|
||
let _: PartialKeyPath<C<A>> = \C.value | ||
let _: KeyPath<C<A>, A> = \C.value | ||
|
@@ -684,7 +684,8 @@ func testSubtypeKeypathClass(_ keyPath: ReferenceWritableKeyPath<Base, Int>) { | |
} | ||
|
||
func testSubtypeKeypathProtocol(_ keyPath: ReferenceWritableKeyPath<PP, Int>) { | ||
testSubtypeKeypathProtocol(\Base.i) // expected-error {{type 'PP' has no member 'i'}} | ||
testSubtypeKeypathProtocol(\Base.i) | ||
// expected-error@-1 {{cannot convert value of type 'ReferenceWritableKeyPath<Base, Int>' to specified type 'ReferenceWritableKeyPath<PP, Int>'}} | ||
} | ||
|
||
// rdar://problem/32057712 | ||
|
Uh oh!
There was an error while loading. Please reload this page.