Skip to content

Commit b0c3dd2

Browse files
committed
[Tests] NFC: Adjust changed test-cases
1 parent 757cc80 commit b0c3dd2

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

test/Constraints/tuple.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ func testTupleLabelMismatchFuncConversion(fn1: @escaping ((x: Int, y: Int)) -> V
363363
}
364364

365365
func testTupleLabelMismatchKeyPath() {
366-
// Very Cursed.
367366
let _: KeyPath<(x: Int, y: Int), Int> = \(a: Int, b: Int).x
368-
// expected-warning@-1 {{tuple conversion from '(a: Int, b: Int)' to '(x: Int, y: Int)' mismatches labels}}
367+
// expected-error@-1 {{key path with root type '(x: Int, y: Int)' cannot be applied to a base of type '(a: Int, b: Int)'}}
368+
// expected-error@-2 {{value of tuple type '(a: Int, b: Int)' has no member 'x'}}
369369
}

test/expr/unary/keypath/keypath.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -959,12 +959,18 @@ func testMemberAccessOnOptionalKeyPathComponent() {
959959
// expected-note@-2 {{chain the optional using '?' to access member 'm' only for non-'nil' base values}} {{17-17=?}}
960960
// expected-note@-3 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}} {{17-17=!}}
961961

962+
// FIXME(diagnostics): Ideally there should be two errors here - one for `b_opt` and one for `c` but since there is
963+
// no contextual type it means that both `!` and `?` could work to reference `.d` and that creates ambiguity which
964+
// is not possible to diagnose at the moment.
962965
_ = \S1a.b_opt.c.d
963966
// expected-error@-1 {{value of optional type 'S1b?' must be unwrapped to refer to member 'c' of wrapped base type 'S1b'}}
964967
// expected-note@-2 {{chain the optional using '?' to access member 'c' only for non-'nil' base values}} {{17-17=?}}
968+
let _: KeyPath<S1a, Int> = \S1a.b_opt.c.d
969+
// expected-error@-1 {{value of optional type 'S1b?' must be unwrapped to refer to member 'c' of wrapped base type 'S1b'}}
970+
// expected-note@-2 {{chain the optional using '?' to access member 'c' only for non-'nil' base values}} {{40-40=?}}
965971
// expected-error@-3 {{value of optional type 'S1c?' must be unwrapped to refer to member 'd' of wrapped base type 'S1c'}}
966-
// expected-note@-4 {{chain the optional using '?' to access member 'd' only for non-'nil' base values}} {{19-19=?}}
967-
// expected-note@-5 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}} {{19-19=!}}
972+
// expected-note@-4 {{chain the optional using '?' to access member 'd' only for non-'nil' base values}} {{42-42=?}}
973+
// expected-note@-5 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}} {{42-42=!}}
968974
_ = \S1a.b_opt?.c.d
969975
// expected-error@-1 {{value of optional type 'S1c?' must be unwrapped to refer to member 'd' of wrapped base type 'S1c'}}
970976
// expected-note@-2 {{chain the optional using '?' to access member 'd' only for non-'nil' base values}} {{20-20=?}}
@@ -1064,7 +1070,8 @@ func f_56996() {
10641070
func f_55805() {
10651071
let _: KeyPath<String?, Int?> = \.utf8.count
10661072
// expected-error@-1 {{key path root inferred as optional type 'String?' must be unwrapped to refer to member 'utf8' of unwrapped type 'String'}}
1067-
// expected-error@-2 {{key path value type 'Int' cannot be converted to contextual type 'Int?'}}
1073+
// expected-error@-2 {{cannot assign value of type 'KeyPath<String?, Int>' to type 'KeyPath<String?, Int?>'}}
1074+
// expected-note@-3 {{arguments to generic parameter 'Value' ('Int' and 'Int?') are expected to be equal}}
10681075
}
10691076

10701077
// rdar://74711236 - crash due to incorrect member access in key path

0 commit comments

Comments
 (0)