-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Change TargetGroup enum param to packageAccess bool in target declaration #6463
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
…tion Resolves rdar://108361064
@swift-ci smoke 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.
LGTM
@swift-ci smoke test |
@swift-ci smoke test windows |
@@ -253,6 +242,7 @@ public final class Target { | |||
resources: [Resource]? = nil, | |||
publicHeadersPath: String?, | |||
type: TargetType, | |||
packageAccess: Bool = false, |
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.
defaulting to false is surprising. most other arguments do not have a default value that impact's behavior so imo this should either not have a default
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.
The resources param above for example has a default value. This removes the need to set the value to false explicitly in Target initialization from static funcs in the earlier versions that do not have this param.
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.
I would prefer this does not have a default as it is driving behavior - just like TargetGroup
did not have a default before
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.
that's reasonable; will make the change
dependencies: [Dependency] = [], | ||
path: String? = nil, | ||
exclude: [String] = [], | ||
sources: [String]? = nil, | ||
resources: [Resource]? = nil, | ||
publicHeadersPath: String? = nil, | ||
packageAccess: Bool = true, |
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.
what does "true" means in this case? that it exposes it symbols to other modules? or that it "can see" other module symbols?
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.
It's both. If another target also has this param set to true, this target exposes its package symbols to that target and also can see package symbols from that target, depending on which target imports which.
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.
so do both modules (definition and consumer) need to be set to "true" for this feature to work?
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.
Yes. In the example below, A cannot access package symbols from B, but B can access package symbols from C. If A imports C, A still cannot access package symbols from C. If C had packageAccess = false, neither A nor B can access package symbols from C.
target A w/ packageAccess = false:
import B
target B w/ packageAccess = true:
import C
target C w/ packageAccess = true:
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.
Most target types have a default of true
, right? So I would think of it the other way around, you set this to false in order to opt-out.
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.
It is set to true by default in the public static func that introduces this param. The Target initializer itself here has the param set to false because it's called by earlier versions of static funcs that should not have access to package symbols.
#6473 removes default param value |
Change TargetGroup enum param to packageAccess bool in target declaration
Resolves rdar://108361064