@@ -1111,3 +1111,42 @@ func test_kp_as_function_mismatch() {
1111
1111
_ = a. filter ( \String . filterOut) // expected-error{{key path value type '(String) throws -> Bool' cannot be converted to contextual type 'Bool'}}
1112
1112
1113
1113
}
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