Skip to content

Conversation

bripeticca
Copy link
Contributor

@bripeticca bripeticca commented Aug 21, 2025

This fix addresses some issues that arose with trait-based dependency resolution on Linux and, found through development, a related issue found involving the swift package show-dependencies command. It fixes an error that was thrown as a discrepancy in state when executing swift package show-dependencies if traits were guarding a dependency and was omitted from the package graph.

Additionally, this will assure that the EnabledTraitsMap guards against explicitly adding "default" traits to the stored dictionary, since this wrapper is a mechanism to determine whether traits have been explicitly set (and therefore have overridden "default" or have flattened the list of default traits).

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.
* 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
* When applicable, the subscript for EnabledTraitsMap will now
  automatically form a union of the existing explicitly enabled
  traits for a package if the package identity exists as a key
  in the stored dictionary (meaning, if the package has already
  been assigned explicitly enabled traits rather than relying
  on "default" traits)
* Clean up code surrounding the use of the traits map, namely
  the redundant checks on whether a package is defaulting to
  default traits vs. explicitly enabled traits
* Add some TODOs in comments to address in next commit
@bripeticca
Copy link
Contributor Author

@swift-ci please test

@bripeticca
Copy link
Contributor Author

@swift-ci please test

Since the wrapper EnabledTraitsMap allows us to determine whether
a package is using default traits by returning ["default"] in place
of nil when a package has not yet been added to the stored dict,
omit explicitly adding "default" to the dictionary itself. This will
allow us to check whether we've explicitly modified the trait configuration
for a given package, since it will override the default set of traits.
@bripeticca
Copy link
Contributor Author

@swift-ci please test

@bripeticca
Copy link
Contributor Author

@swift-ci please test windows

@bripeticca
Copy link
Contributor Author

@swift-ci please test

@bripeticca
Copy link
Contributor Author

@swift-ci please test windows

@bripeticca
Copy link
Contributor Author

@swift-ci please test

@bripeticca
Copy link
Contributor Author

@swift-ci please test windows

@bripeticca
Copy link
Contributor Author

@swift-ci please test self hosted windows

@bripeticca bripeticca enabled auto-merge (squash) September 4, 2025 19:14
Update an area of code that used legacy methods to compute enabled
traits of a dependency prior to the introduction of the EnabledTraitsMap.
@bripeticca
Copy link
Contributor Author

@swift-ci please test

@bripeticca
Copy link
Contributor Author

@swift-ci please test windows

@bripeticca
Copy link
Contributor Author

@swift-ci please test self hosted windows

2 similar comments
@bripeticca
Copy link
Contributor Author

@swift-ci please test self hosted windows

@bripeticca
Copy link
Contributor Author

@swift-ci please test self hosted windows

@bripeticca bripeticca merged commit 015c647 into swiftlang:main Sep 10, 2025
6 checks passed
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