-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix @dynamicMemberLookup
for protocol/archetype types.
#20516
Fix @dynamicMemberLookup
for protocol/archetype types.
#20516
Conversation
@swift-ci Please smoke test EDIT: Linux tests failed with a weird unrelated error: |
@dan-zheng Take a look at extractDirectlyReferencedNominalTypes() in lib/AST/NameLookup.cpp. Do you think this can be useful for @dynamicCallable and @dynamicMemberLookup? More generally it would be nice to factor out a common superclass/conforming protocol walk for use by name lookup and these attributes. If you think about it what they're doing is very similar to name lookup except they're searching for an attribute and not a member. |
@slavapestov Thanks for the suggestion!
A common superclass/protocol type walk function definitely makes sense. I'm happy to look into it, perhaps we can merge this PR to unblock progress in the meantime. |
9f8da92
to
35a8a16
Compare
I got some weird test failures regarding |
@shahmishal: you're probably aware of this already, but do you know why CI is failing with Example build job. |
@milseman Is this related to cherry-pick on clang/llvm branch? |
@dan-zheng @shahmishal Jordan pushed a fix for the PCH issue, tests should pass now. |
@dan-zheng Why would the order matter? |
@slavapestov It shouldn't, I was being overly cautious. 😃 EDIT: I'll probably augment |
@swift-ci Please smoke test |
@dan-zheng Yeah, I would first make the function public and use it in the implementation of those attributes, and make sure there are no regressions, etc. Then I would think about extracting the nominal type visitation logic as a separate task. |
I'm +1 on this patch (including the testcase), but am sufficiently far enough away from the code to not be the best reviewer. Is anyone else able to give this a sniff test? |
cc @slavapestov @rudkx: could you please review? As suggested by Slava, in a follow-up PR, I plan to make |
- Enable `subscript(dynamicMember:)` as a requirement for `@dynamicMemberLookup` protocols. - Add tests. - Minor `@dynamicCallable`-related gardening. Resolves SR-8077.
35a8a16
to
70becc3
Compare
Added a |
@@ -3552,8 +3569,8 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName, | |||
constraintKind == ConstraintKind::ValueMember && | |||
memberName.isSimpleName() && !memberName.isSpecial()) { | |||
auto name = memberName.getBaseIdentifier(); | |||
if (hasDynamicMemberLookupAttribute(instanceTy->getCanonicalType(), | |||
DynamicMemberLookupCache)) { | |||
// TC.extract |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, accidentally committed this rogue comment.
I'll remove in my next PR, if it's not gone by then.
Removed in #20567.
Enable
subscript(dynamicMember:)
as a requirement for@dynamicMemberLookup
protocols.Previously,
@dynamicMemberLookup
protocols could only definesubscript(dynamicMember:)
in an extension. This patch fixes that.Resolves SR-8077.
There's also some
@dynamicCallable
-related gardening.