Skip to content

Gardening for @dynamicMemberLookup. #20498

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

Merged
merged 2 commits into from
Nov 12, 2018

Conversation

dan-zheng
Copy link
Contributor

@dan-zheng dan-zheng commented Nov 11, 2018

  • Unify code style of @dynamicMemberLookup and @dynamicCallable implementations.
    • Use consistent variable names, diagnostic names/messages, doc comments, etc.
  • Move @dynamicMemberLookup test to test/attr directory.

New consistent naming:

  • invalid_dynamic_callable_type, invalid_dynamic_member_lookup_type
  • DynamicCallableCache, DynamicMemberLookupCache
  • isValidDynamicCallableMethod, isValidDynamicMemberLookupSubscript

This PR is almost NFC. The only user-facing change is a new error message for invalid_dynamic_member_lookup_type.

@dan-zheng
Copy link
Contributor Author

cc @lattner: could you please review?

@dan-zheng dan-zheng changed the title [NFC] Gardening for @dynamicMemberLookup. Gardening for @dynamicMemberLookup. Nov 11, 2018
@@ -3053,17 +3053,17 @@ getArgumentLabels(ConstraintSystem &cs, ConstraintLocatorBuilder locator) {
/// conformances, but this is fine because it doesn't get invoked in the normal
/// name lookup path (only when lookup is about to fail).
static bool hasDynamicMemberLookupAttribute(CanType ty,
Copy link
Contributor Author

@dan-zheng dan-zheng Nov 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deduping this function with getDynamicCallableMethods (which also defines the same "type traversal" logic) would be nice. However, the two functions use different cache types (llvm::DenseMap<CanType, bool> vs llvm::DenseMap<CanType, DynamicCallableMethods>), which makes generalization difficult. 🙁

Any generalization ideas appreciated.

- Unify code style of `@dynamicMemberLookup` and `@dynamicCallable` implementations.
  - Use consistent variable names, doc comments, etc.
- Move `@dynamicMemberLookup` test to `test/attr` directory.
@dan-zheng dan-zheng force-pushed the dynamic-member-lookup-cleanup branch from b98388b to 6583acd Compare November 11, 2018 16:59
@dan-zheng
Copy link
Contributor Author

@swift-ci Please smoke test

1 similar comment
@dan-zheng
Copy link
Contributor Author

@swift-ci Please smoke test

@lattner
Copy link
Contributor

lattner commented Nov 12, 2018

This all LGTM, but please fix the attr/attr_dynamic_member_lookup.swift failure.

@dan-zheng dan-zheng force-pushed the dynamic-member-lookup-cleanup branch from 18a8ea9 to 9f46a53 Compare November 12, 2018 00:38
@dan-zheng
Copy link
Contributor Author

Sorry, tests failed because I updated the diagnostic message without updating tests.
@swift-ci Please smoke test

@dan-zheng dan-zheng merged commit 2863b6c into swiftlang:master Nov 12, 2018
@dan-zheng dan-zheng deleted the dynamic-member-lookup-cleanup branch November 12, 2018 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants