-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix for .when(traits:) condition not working for multiple traits #9015
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 for .when(traits:) condition not working for multiple traits #9015
Conversation
The culprit here is the fact that we were essentially doing an AND boolean check across all the traits in the target dependency condition, when we should be doing an OR boolean check. If at least one trait is enabled in the list of traits in the target dependency condition, then the target dependecy should be considered enabled as well.
@swift-ci please test |
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.
Great catch! Can we add to our trait fixtures this setup as well where a single dependency is guarded by two traits?
@swift-ci please test |
@swift-ci please test windows |
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.
Some comments for your consideration.
* Added a wrapper struct that contains a list of traits that could be passed as an argument + the expected output for said combination for TraitTests * Added extra test cases to traits-related Manifest tests, accounting for target dependencies that are enabled by many traits
@swift-ci please test |
@swift-ci please test |
@swift-ci please test windows |
@swift-ci please test self hosted windows |
…ftlang#9015) The culprit here is the fact that we were essentially doing an AND boolean check across all the traits in the target dependency condition, when we should be doing an OR boolean check. If at least one trait is enabled in the list of traits in the target dependency condition, then the target dependecy should be considered enabled as well.
…ftlang#9015) The culprit here is the fact that we were essentially doing an AND boolean check across all the traits in the target dependency condition, when we should be doing an OR boolean check. If at least one trait is enabled in the list of traits in the target dependency condition, then the target dependecy should be considered enabled as well.
…ftlang#9015) The culprit here is the fact that we were essentially doing an AND boolean check across all the traits in the target dependency condition, when we should be doing an OR boolean check. If at least one trait is enabled in the list of traits in the target dependency condition, then the target dependecy should be considered enabled as well.
…tion when loading dependency manifests (#9141) - **Explanation**: Addresses multiple traits issues: - Changes the check for trait-guarded target dependencies to determine whether the package dependency from which it derives is used in the parent package; prior to this change, the check was asserting that *all* traits in the `when` condition of a target dependency were enabled for the dependency to be considered unguarded, but now the check confirms that *at least one* trait in the condition is enabled. - Fixes some errors in trait computation that hadn't considered when default traits ["default"] were being appended to the EnabledTraitsMap, which should only consider a list of flattened traits + explicitly enabled traits by a user/parent package. The inclusion of default in this dictionary was resulting in an inaccurate computation of which traits were enabled, since pre-computation serves to flatten the list of transitively enabled traits for future reference. There were also cases where we were re-computing transitively enabled traits in areas where we had already filled out the enabledTraitsMap, so we now default to simply fetching the entry from the dictionary instead of computing the traits all over again. - **Scope**: Package resolution stage; particularly affects pre-computation of transitively enabled traits when determining which target dependencies are/aren't guarded by traits. Also allows for multiple traits to be considered in a target dependency's `when` condition, any of which being enabled would then include said target dependency. - **Issues**: - **Original PRs**: #9015 #9057 - **Risk**: Low risk; fixes trait-related issues. - **Testing**: Fixtures added for end-to-end testing of the issue; regression tests added to multiple suites - **Reviewers**: @FranzBusch @jakepetroules @dschaefer2
…ftlang#9015) The culprit here is the fact that we were essentially doing an AND boolean check across all the traits in the target dependency condition, when we should be doing an OR boolean check. If at least one trait is enabled in the list of traits in the target dependency condition, then the target dependecy should be considered enabled as well.
The culprit here is the fact that we were essentially doing an AND boolean check across all the traits in the target dependency condition, when we should be doing an OR boolean check.
If at least one trait is enabled in the list of traits in the target dependency condition, then the target dependecy should be considered enabled as well.