-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Enable aliasing a property that is forwarded in at the same level #24
Enable aliasing a property that is forwarded in at the same level #24
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## dfed--renamed-received-resolution #24 +/- ##
=====================================================================
+ Coverage 99.28% 99.32% +0.03%
=====================================================================
Files 37 38 +1
Lines 8304 8597 +293
=====================================================================
+ Hits 8245 8539 +294
+ Misses 59 58 -1
|
0d3ebd4
to
839d704
Compare
@@ -68,13 +68,10 @@ jobs: | |||
linux: | |||
name: Build and Test on Linux | |||
runs-on: ubuntu-latest | |||
container: swift:5.9 |
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.
following the advice here to avoid this kind of CI failure
d7fa806
to
5c4ab59
Compare
let forwardedProperties = Set( | ||
scope | ||
.instantiable | ||
.dependencies | ||
.filter(\.isForwarded) | ||
.map(\.property) | ||
) | ||
for receivedProperty in scope.receivedProperties { | ||
let parentContainsProperty = receivableProperties.contains(receivedProperty) | ||
if !parentContainsProperty { | ||
let propertyIsForwarded = forwardedProperties.contains(receivedProperty) | ||
if !parentContainsProperty && !propertyIsForwarded { |
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.
this is the crux of the change that makes the new tests pass. We were already inspecting properties that were forwarded by a higher-up scope (they're in receivedProperties
), but we weren't inspecting the properties in out scope.
case .ifConfigDecl: | ||
return false | ||
} | ||
element.instantiableMacro != nil |
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 simplified our macro access while I was adding associated types to the Dependency.Source
enum in order to share this code.
@@ -35,7 +35,7 @@ public enum FixableInstantiableError: DiagnosticError { | |||
public var description: String { | |||
switch self { | |||
case .dependencyHasTooManyAttributes: | |||
"Dependency can have at most one of @\(Dependency.Source.instantiated), @\(Dependency.Source.received), or @\(Dependency.Source.forwarded) attached macro" |
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.
Dependency.Source
is no longer a String
-backed enum, so we need to use constants for these raw values now.
Closing in favor of #26 |
Fixes an issue where we could rename properties that were forwarded in above us, but not at the same level.
Due to our insight in #23 #23 (comment) (the PR on which this depends), I have rewritten
Dependency.Source
to have a separate case for an alias. By adding associated values to the enum, we were able to remove multiple optional properties and hard-to-keep-track-of tribal knowledge in the codebase.Because we have updated the
Dependency.Source
whichSafeDITool
may persist, this PR is a breaking change and we will need to roll to a 0.3.0 when this merges.On top of that, this is a pretty meaty change. I recommend reviewing this change in side-by-side view and turning off whitespace diffs to best understand what we were accomplishing before vs after.