-
Notifications
You must be signed in to change notification settings - Fork 204
[5.5, NFC, Incremental] Create a domain-specific type for the inputDependencySourceMap #710
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
@swift-ci please test |
…ncySourceMap Will facilitate making it immutable
d538883
to
fe7100a
Compare
@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.
LGTM for the 5.5 branch.
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 not clear to me what invariants are captured by this data structure and why this refactoring needs to go into 5.5.
public typealias BiMap = BidirectionalMap<TypedVirtualPath, DependencySource> | ||
@_spi(Testing) public var biMap = BiMap() | ||
|
||
private let simulateGetInputFailure: Bool |
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.
Why is this a format part of the API? We know how to create this failure mode in tests for the current implementation, and the new one should structurally avoid the issue altogether.
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.
simulateGetInputFailure
is gone on the main branch. It remains here in the interest of minimal changes to this branch. If you insist, I'm happy with removing it. Whatever the folks in charge of this branch prefer.
// MARK: - Populating | ||
extension InputDependencySourceMap { | ||
public enum AdditionPurpose { | ||
case mocking, |
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.
Please document these
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.
Good point! Will do.
extension InputDependencySourceMap { | ||
@_spi(Testing) public func sourceIfKnown(for input: TypedVirtualPath) -> DependencySource? { | ||
biMap[input] | ||
} | ||
|
||
@_spi(Testing) public func inputIfKnown(for source: DependencySource) -> TypedVirtualPath? { | ||
simulateGetInputFailure ? nil : biMap[source] | ||
} | ||
|
||
@_spi(Testing) public func enumerateToSerializePriors( | ||
_ eachFn: (TypedVirtualPath, DependencySource) -> Void | ||
) { | ||
biMap.forEach(eachFn) | ||
} | ||
} | ||
|
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.
Would very much prefer we not conflate the point of use with the names of these APIs.
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.
Could you please elaborate? I want to be sure I understand the point here. What would you suggest instead?
If you feel that enumerateToSerializePriors
is too specific, then we probably disagree about the value of intention-revealing names.
If that is the source of disagreement, here is a nice quote I found that explains what I am trying to accomplish:
If a developer must consider the implementation of a component in order to use it, the value of encapsulation is lost. If someone other than the original developer must infer the purpose of an object or operation based on its implementation, that new developer may infer a purpose that the operation or class fulfills only by chance. If that was not the intent, the code may work for the moment, but the conceptual basis of the design will have been corrupted, and the two developers will be working at cross-purposes.
Therefore,
Name classes and operations to describe their effect and purpose, without reference to the means by which they do what they promise. This relieves the client developer of the need to understand the internals.
Thank you! |
I understand your preference, and the custom type does add one more term to the vocabulary here. Here's why I think that this type eases maintenance: Because it: Provides a focus for an overall comment, Most of all, it lays the foundation for #712, by isolating the locus of the change. |
@swift-ci please test |
@CodaFi Thanks a lot for taking a look at this. I was hoping you would verify that this refactoring introduces no functional change. From what I can tell your comments relate to: the maintenance value of the refactoring, and the choice of names. (I have added documentation per your request.) Is this assessment of your review correct? If so, I am heartened by your assessment. Thank you again! |
a0f4df5
to
f875561
Compare
@swift-ci please test |
@swift-ci please test macos platform |
This is sidestepping the primary issues with this patch(set). I have expressed concerns from the start about merging a large patchset including refactoring to the release branch without additional qualification or sufficient time to seed to users both internally and externally so we can detect issues before release. We should be shooting for narrow fixes to issues, as you yourself articulated upthread, and there is a much more narrow course of action here: Only using the output file map as a source of truth. I do not understand why the rest of the refactoring needs to come along for the ride. |
Do you mean that, although you cannot identify a functional change from the refactoring, in the interest of reducing risk for the beta, you advocate the functional change of making the |
Cherry-pick of #685 for the
release/5.5
branch.