@dynamicMemberLookup on protocols

Thanks for pointing this out!

That @dynamicMemberLookup doesn't work for protocols is known and a bug in my opinon. I believe @Chris_Lattner3 agreed that it's a bug but I can't find the post where he stated that.

Here's a previous post illustrating the problem and an ineffective workaround.

I believe @dynamicMemberLookup (and @dynamicCallable) should be declarable on protocols.
Method resolution for dynamic member lookups and dynamic calls should work just like resolution for protocol requirements.

I'm currently working on the @dynamicCallable implementation and intend to fix @dynamicMemberLookup for protocols at some point (before Swift 5).

2 Likes