Skip to content

Commit 0235ff1

Browse files
committed
[Sema] Adjust invalid @dynamicMemberLookup to mention keypath parameter
1 parent 2c82882 commit 0235ff1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,8 +1057,8 @@ ERROR(missing_dynamic_callable_kwargs_method,none,
10571057

10581058
ERROR(invalid_dynamic_member_lookup_type,none,
10591059
"@dynamicMemberLookup attribute requires %0 to have a "
1060-
"'subscript(dynamicMember:)' method with an "
1061-
"'ExpressibleByStringLiteral' parameter", (Type))
1060+
"'subscript(dynamicMember:)' method that accepts either "
1061+
"'ExpressibleByStringLiteral' or a keypath", (Type))
10621062

10631063
ERROR(string_index_not_integer,none,
10641064
"String must not be indexed with %0, it has variable size elements",

test/attr/attr_dynamic_member_lookup.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func testIUOResult(x: IUOResult) {
140140
// Subscript index must be ExpressibleByStringLiteral.
141141
@dynamicMemberLookup
142142
struct Invalid1 {
143-
// expected-error @+1 {{@dynamicMemberLookup attribute requires 'Invalid1' to have a 'subscript(dynamicMember:)' method with an 'ExpressibleByStringLiteral' parameter}}
143+
// expected-error @+1 {{@dynamicMemberLookup attribute requires 'Invalid1' to have a 'subscript(dynamicMember:)' method that accepts either 'ExpressibleByStringLiteral' or a keypath}}
144144
subscript(dynamicMember member: Int) -> Int {
145145
return 42
146146
}
@@ -149,7 +149,7 @@ struct Invalid1 {
149149
// Subscript may not be variadic.
150150
@dynamicMemberLookup
151151
struct Invalid2 {
152-
// expected-error @+1 {{@dynamicMemberLookup attribute requires 'Invalid2' to have a 'subscript(dynamicMember:)' method with an 'ExpressibleByStringLiteral' parameter}}
152+
// expected-error @+1 {{@dynamicMemberLookup attribute requires 'Invalid2' to have a 'subscript(dynamicMember:)' method that accepts either 'ExpressibleByStringLiteral' or a keypath}}
153153
subscript(dynamicMember member: String...) -> Int {
154154
return 42
155155
}
@@ -188,7 +188,7 @@ func NotAllowedOnFunc() {}
188188
// @dynamicMemberLookup cannot be declared on a base class and fulfilled with a
189189
// derived class.
190190

191-
// expected-error @+1 {{@dynamicMemberLookup attribute requires 'InvalidBase' to have a 'subscript(dynamicMember:)' method with an 'ExpressibleByStringLiteral' parameter}}
191+
// expected-error @+1 {{@dynamicMemberLookup attribute requires 'InvalidBase' to have a 'subscript(dynamicMember:)' method that accepts either 'ExpressibleByStringLiteral' or a keypath}}
192192
@dynamicMemberLookup
193193
class InvalidBase {}
194194

0 commit comments

Comments
 (0)