Skip to content

Requestify AbstractStorageDecl::hasStorage(). #66482

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 4 commits into from
Jun 12, 2023

Conversation

DougGregor
Copy link
Member

The hasStorage() computation is used in many places to determine the signatures of other declarations. It currently needs to expand accessor macros, which causes a number of cyclic references. Provide a simplified request to determine hasStorage without expanding or resolving macros, breaking a common pattern of cycles when using macros.

Fixes rdar://109668383.

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor force-pushed the requestify-has-storage branch from 245a3d5 to 5be151e Compare June 9, 2023 22:04
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor DougGregor force-pushed the requestify-has-storage branch from 5be151e to 655f35c Compare June 10, 2023 05:36
@DougGregor
Copy link
Member Author

@swift-ci please clean smoke test

The `hasStorage()` computation is used in many places to determine the
signatures of other declarations. It currently needs to expand accessor
macros, which causes a number of cyclic references. Provide a
simplified request to determine `hasStorage` without expanding or
resolving macros, breaking a common pattern of cycles when using
macros.

Fixes rdar://109668383.
… impl info

Slightly cleanup, and make an assertion less strict in the face of invalid
code.
Now that we've made accessor macro expansion more lazy, ensure that
when querying for init accessors (e.g., to build a memberwise
initializer), we also expand any accessor macros that might produce an
init accessor.

This is a partial step toward the real goal, which is that
`AbstractStorageDecl::getAccessor()` should lazily expand macros if
needed.

Update the Observable macro to document that it produces an `init`
accessor.
Remove an early iteration of cycle-breaking in `PatternBindingEntryRequest`
that has been subsumed by the lazy computation of
`AbstractStorageDecl::hasStorage()`. We can now directly use
`hasStorage()` here.
@DougGregor DougGregor force-pushed the requestify-has-storage branch from 655f35c to 5457290 Compare June 11, 2023 15:54
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit bcb01ce into swiftlang:main Jun 12, 2023
@DougGregor DougGregor deleted the requestify-has-storage branch June 12, 2023 05:06
bnbarham added a commit that referenced this pull request Jun 12, 2023
#66497 and
#66482 succeeded separately, then
merged. But after 66497 the error now includes parentheses.

Resolves rdar://110655182.
#if OBSERVATION_SUPPORTS_PEER_MACROS
@attached(peer, names: prefixed(_))
#endif
public macro ObservationTracked() =
#externalMacro(module: "ObservationMacros", type: "ObservationTrackedMacro")

@available(SwiftStdlib 5.9, *)
@attached(accessor)
@attached(accessor, names: named(willSet))

Choose a reason for hiding this comment

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

Hi everyone,

I was reviewing this old PR and came across the names: named(willSet) argument. I don't get why this has been added. Does anyone recall the specific reason for adding this?

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.

2 participants