Skip to content

Commit 8f02d76

Browse files
committed
[Diagnostics] NFC: Adjust a couple of improved key path diagnostics
1 parent c47a40c commit 8f02d76

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/expr/unary/keypath/keypath.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@ func testKeyPath(sub: Sub, optSub: OptSub,
180180
var m = [\A.property, \A.[sub], \A.optProperty!]
181181
expect(&m, toHaveType: Exactly<[PartialKeyPath<A>]>.self)
182182

183-
// FIXME: shouldn't be ambiguous
184-
// expected-error@+1{{ambiguous}}
183+
// \.optProperty returns an optional of Prop and `\.[sub]` returns `A`
184+
// expected-error@+2 {{key path value type 'Prop?' cannot be converted to contextual type 'Prop'}}
185+
// expected-error@+1 {{key path value type 'A' cannot be converted to contextual type 'Prop'}}
185186
var n = [\A.property, \.optProperty, \.[sub], \.optProperty!]
186187
expect(&n, toHaveType: Exactly<[PartialKeyPath<A>]>.self)
187188

@@ -229,7 +230,9 @@ func testDisembodiedStringInterpolation(x: Int) {
229230

230231
func testNoComponents() {
231232
let _: KeyPath<A, A> = \A // expected-error{{must have at least one component}}
233+
// FIXME(diagnostics): This should be diagnosed as `missing generic parameter 'T'` instead of a contextual failure.
232234
let _: KeyPath<C, A> = \C // expected-error{{must have at least one component}} expected-error{{}}
235+
// expected-error@-1 {{cannot convert value of type 'KeyPath<Root, Value>' to specified type 'KeyPath<C<Any>, A>'}}
233236
}
234237

235238
struct TupleStruct {

0 commit comments

Comments
 (0)