Skip to content

Commit ac78421

Browse files
Merge pull request #37471 from LucianoPAlmeida/SR-14499-regression-test
[NFC][tests] Add regression tests for SR-14499
2 parents 7e2a7ca + 0b0279f commit ac78421

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/expr/unary/keypath/keypath.swift

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,3 +1111,42 @@ func test_kp_as_function_mismatch() {
11111111
_ = a.filter(\String.filterOut) // expected-error{{key path value type '(String) throws -> Bool' cannot be converted to contextual type 'Bool'}}
11121112

11131113
}
1114+
1115+
// SR-14499
1116+
struct SR14499_A { }
1117+
struct SR14499_B { }
1118+
1119+
func sr14499() {
1120+
func reproduceA() -> [(SR14499_A, SR14499_B)] {
1121+
[
1122+
(true, .init(), SR14499_B.init()) // expected-error {{cannot infer contextual base in reference to member 'init'}}
1123+
]
1124+
.filter(\.0) // expected-error {{value of type 'Any' has no member '0'}}
1125+
// expected-note@-1 {{cast 'Any' to 'AnyObject' or use 'as!' to force downcast to a more specific type to access members}}
1126+
.prefix(3)
1127+
.map { ($0.1, $0.2) } // expected-error {{value of type 'Any' has no member '1'}} expected-error{{value of type 'Any' has no member '2'}}
1128+
// expected-note@-1 2 {{cast 'Any' to 'AnyObject' or use 'as!' to force downcast to a more specific type to access members}}
1129+
}
1130+
1131+
func reproduceB() -> [(SR14499_A, SR14499_B)] {
1132+
[
1133+
(true, SR14499_A.init(), .init()) // expected-error {{cannot infer contextual base in reference to member 'init'}}
1134+
]
1135+
.filter(\.0) // expected-error {{value of type 'Any' has no member '0'}}
1136+
// expected-note@-1 {{cast 'Any' to 'AnyObject' or use 'as!' to force downcast to a more specific type to access members}}
1137+
.prefix(3)
1138+
.map { ($0.1, $0.2) } // expected-error {{value of type 'Any' has no member '1'}} expected-error{{value of type 'Any' has no member '2'}}
1139+
// expected-note@-1 2 {{cast 'Any' to 'AnyObject' or use 'as!' to force downcast to a more specific type to access members}}
1140+
}
1141+
1142+
func reproduceC() -> [(SR14499_A, SR14499_B)] {
1143+
[
1144+
(true, .init(), .init()) // expected-error 2 {{cannot infer contextual base in reference to member 'init'}}
1145+
]
1146+
.filter(\.0) // expected-error {{value of type 'Any' has no member '0'}}
1147+
// expected-note@-1 {{cast 'Any' to 'AnyObject' or use 'as!' to force downcast to a more specific type to access members}}
1148+
.prefix(3)
1149+
.map { ($0.1, $0.2) } // expected-error {{value of type 'Any' has no member '1'}} expected-error{{value of type 'Any' has no member '2'}}
1150+
// expected-note@-1 2 {{cast 'Any' to 'AnyObject' or use 'as!' to force downcast to a more specific type to access members}}
1151+
}
1152+
}

0 commit comments

Comments
 (0)