Skip to content

Improve check for unsafe flags #2845

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

Conversation

neonichu
Copy link
Contributor

@neonichu neonichu commented Aug 4, 2020

We prohibit unsafe flags in package dependencies, but the check was only looking at targets which are direct dependencies of a product, not transitive ones.

rdar://problem/66499615

@@ -570,8 +570,11 @@ private final class ResolvedTargetBuilder: ResolvedBuilder<ResolvedTarget> {
}

func diagnoseInvalidUseOfUnsafeFlags(_ product: ResolvedProduct) {
let inputTargets = product.targets
let recursiveDependencies = inputTargets.lazy.flatMap { $0.recursiveDependencies() }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be recursiveTargetDependencies

@@ -570,8 +570,11 @@ private final class ResolvedTargetBuilder: ResolvedBuilder<ResolvedTarget> {
}

func diagnoseInvalidUseOfUnsafeFlags(_ product: ResolvedProduct) {
let inputTargets = product.targets
let recursiveDependencies = inputTargets.lazy.flatMap { $0.recursiveDependencies() }
let reachableTargets = Set(inputTargets).union(recursiveDependencies.compactMap { $0.target })
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe worth making this a property of product rather than a local thing

Copy link
Contributor

Choose a reason for hiding this comment

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

We already have recursiveTargetDependencies computed property as commented above

Copy link
Contributor

Choose a reason for hiding this comment

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

nice. your comment above sounded like you wanted the variable to renamed

We prohibit unsafe flags in package dependencies, but the check was only
looking at targets which are direct dependencies of a product, not
transitive ones.

rdar://problem/66499615
@neonichu neonichu force-pushed the handle-unsafe-flags-in-transitive-targets branch from 5389245 to b9fcfa4 Compare August 6, 2020 20:39
@neonichu
Copy link
Contributor Author

neonichu commented Aug 6, 2020

@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

neonichu commented Aug 6, 2020

Looks like this ran into the known module cache issue.

@neonichu
Copy link
Contributor Author

neonichu commented Aug 6, 2020

@swift-ci please smoke test

@neonichu neonichu merged commit 6f469cf into swiftlang:master Aug 6, 2020
@neonichu neonichu deleted the handle-unsafe-flags-in-transitive-targets branch August 6, 2020 23:53
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