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
Using @dynamicMemberLookup as a protocol requirement without a default implementation for the subscript produces a compile error:
// error: @dynamicMemberLookup attribute requires 'P'// to have a 'subscript(dynamicMember:)' member with// a string index@dynamicMemberLookupprotocolP {
subscript(dynamicMembermember: String) -> String { get }
}
Adding a default implementation for the subscript compiles and works correctly:
This is because subscript(dynamicMember🙂 lookup does not search through protocol requirements, only concrete methods.
This is a bug, not a feature. The @dynamicCallable implementation fixed this bug but the logic needs to be backported to @dynamicMemberLookup. I'll handle this before the Swift 5 release cutoff.
Environment
Tested in:
Xcode 10b2, Apple Swift version 4.2 (swiftlang-1000.0.16.9 clang-1000.10.25.3)
and with the Swift-Development-Snapshot-2018-06-20-a toolchain.
Additional Detail from JIRA
md5: 5a6078ecbd3a511f4ebcc3bee56fffa2
Issue Description:
See the associated Swift forums discussion.
Using
@dynamicMemberLookup
as a protocol requirement without a default implementation for the subscript produces a compile error:Adding a default implementation for the subscript compiles and works correctly:
The text was updated successfully, but these errors were encountered: