Skip to content

Give OptionSet an initializer_list constructor #32447

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 1 commit into from
Jun 23, 2020

Conversation

martinboehme
Copy link
Contributor

This makes it easier to specify OptionSet arguments.

Also modify appropriate uses of ModuleDecl::ImportFilter to take advantage of the new constructor.

@martinboehme
Copy link
Contributor Author

@swift-ci Please test

@martinboehme martinboehme requested a review from gribozavr June 18, 2020 13:48
@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - af6b58fdadf6f798cf0375cc2009e6b5deee2444

@martinboehme
Copy link
Contributor Author

@swift-ci Please test OS X

@martinboehme martinboehme force-pushed the option-set-initializer-list branch from af6b58f to 4528dbf Compare June 19, 2020 12:12
@martinboehme
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - af6b58fdadf6f798cf0375cc2009e6b5deee2444

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - af6b58fdadf6f798cf0375cc2009e6b5deee2444

@@ -58,6 +59,10 @@ class OptionSet {
/// Create an option set with only the given option set.
constexpr OptionSet(Flags flag) : Storage(static_cast<StorageType>(flag)) {}

/// Create an option set containing the given options.
constexpr OptionSet(std::initializer_list<Flags> flags)
Copy link
Contributor

Choose a reason for hiding this comment

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

This constructor cannot be constexpr unless combineFlags is constexpr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Huh, of course. Done.

I'm surprised the compiler didn't complain about this?

ImportFilter |= ModuleDecl::ImportFilterKind::Public;
ImportFilter |= ModuleDecl::ImportFilterKind::Private;
ImportFilter |= ModuleDecl::ImportFilterKind::ImplementationOnly;
ModuleDecl::ImportFilter ImportFilter = {
Copy link
Contributor

Choose a reason for hiding this comment

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

constexpr here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

ModuleDecl::ImportFilter ImportFilter;
ImportFilter |= ModuleDecl::ImportFilterKind::Public;
ImportFilter |= ModuleDecl::ImportFilterKind::Private;
ModuleDecl::ImportFilter ImportFilter = {
Copy link
Contributor

Choose a reason for hiding this comment

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

And here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That doesn't work because ImportFilter is modified below.

@martinboehme martinboehme force-pushed the option-set-initializer-list branch from 4528dbf to 91674cb Compare June 22, 2020 04:56
This makes it easier to specify OptionSet arguments.

Also modify appropriate uses of ModuleDecl::ImportFilter to take
advantage of the new constructor.
@martinboehme martinboehme force-pushed the option-set-initializer-list branch from 91674cb to d806ba5 Compare June 22, 2020 04:57
@martinboehme
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 4528dbfe9f213ad8de507705378642a2f847812f

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 4528dbfe9f213ad8de507705378642a2f847812f

@CodaFi
Copy link
Contributor

CodaFi commented Jun 23, 2020

@CodaFi CodaFi merged commit 0da060e into swiftlang:master Jun 23, 2020
@martinboehme martinboehme deleted the option-set-initializer-list branch June 24, 2020 06:13
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.

4 participants