You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Subscript index must be ExpressibleByStringLiteral.
141
141
@dynamicMemberLookup
142
142
structInvalid1{
143
-
// expected-error @+1 {{@dynamicMemberLookup attribute requires 'Invalid1' to have a 'subscript(dynamicMember:)' method that accepts either 'ExpressibleByStringLiteral' or a keypath}}
143
+
// expected-error @+1 {{@dynamicMemberLookup attribute requires 'Invalid1' to have a 'subscript(dynamicMember:)' method that accepts either 'ExpressibleByStringLiteral' or a key path}}
144
144
subscript(dynamicMember member:Int)->Int{
145
145
return42
146
146
}
@@ -149,7 +149,7 @@ struct Invalid1 {
149
149
// Subscript may not be variadic.
150
150
@dynamicMemberLookup
151
151
structInvalid2{
152
-
// expected-error @+1 {{@dynamicMemberLookup attribute requires 'Invalid2' to have a 'subscript(dynamicMember:)' method that accepts either 'ExpressibleByStringLiteral' or a keypath}}
152
+
// expected-error @+1 {{@dynamicMemberLookup attribute requires 'Invalid2' to have a 'subscript(dynamicMember:)' method that accepts either 'ExpressibleByStringLiteral' or a key path}}
153
153
subscript(dynamicMember member:String...)->Int{
154
154
return42
155
155
}
@@ -188,7 +188,7 @@ func NotAllowedOnFunc() {}
188
188
// @dynamicMemberLookup cannot be declared on a base class and fulfilled with a
189
189
// derived class.
190
190
191
-
// expected-error @+1 {{@dynamicMemberLookup attribute requires 'InvalidBase' to have a 'subscript(dynamicMember:)' method that accepts either 'ExpressibleByStringLiteral' or a keypath}}
191
+
// expected-error @+1 {{@dynamicMemberLookup attribute requires 'InvalidBase' to have a 'subscript(dynamicMember:)' method that accepts either 'ExpressibleByStringLiteral' or a key path}}
192
192
@dynamicMemberLookup
193
193
classInvalidBase{}
194
194
@@ -722,3 +722,25 @@ struct SR10597_1_W<T> {
722
722
723
723
_ =SR10597_1_W<SR10597_1>(SR10597_1()).wooo // expected-error {{value of type 'SR10597_1_W<SR10597_1>' has no dynamic member 'wooo' using key path from root type 'SR10597_1'; did you mean 'woo'?}}
724
724
_ =SR10597_1_W<SR10597_1>(SR10597_1()).bla // expected-error {{value of type 'SR10597_1_W<SR10597_1>' has no dynamic member 'bla' using key path from root type 'SR10597_1'}}
725
+
726
+
// SR-10557
727
+
728
+
@dynamicMemberLookup
729
+
structSR_10557_S{
730
+
subscript(dynamicMember:String)->String{ // expected-error {{@dynamicMemberLookup attribute requires 'SR_10557_S' to have a 'subscript(dynamicMember:)' method that accepts either 'ExpressibleByStringLiteral' or a key path}}
731
+
// expected-note@-1 {{add an explicit argument label to this subscript to satisfy the @dynamicMemberLookup requirement}}{{13-13=dynamicMember }}
732
+
fatalError()
733
+
}
734
+
}
735
+
736
+
@dynamicMemberLookup
737
+
structSR_10557_S1{
738
+
subscript(foo bar:String)->String{ // expected-error {{@dynamicMemberLookup attribute requires 'SR_10557_S1' to have a 'subscript(dynamicMember:)' method that accepts either 'ExpressibleByStringLiteral' or a key path}}
739
+
fatalError()
740
+
}
741
+
742
+
subscript(foo:String)->String{ // expected-error {{@dynamicMemberLookup attribute requires 'SR_10557_S1' to have a 'subscript(dynamicMember:)' method that accepts either 'ExpressibleByStringLiteral' or a key path}}
743
+
// expected-note@-1 {{add an explicit argument label to this subscript to satisfy the @dynamicMemberLookup requirement}} {{13-13=dynamicMember }}
0 commit comments