Skip to content
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

fix(injector): source import shadowed results in build error "X is not a type" #463

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

eliottness
Copy link
Contributor

@eliottness eliottness commented Dec 11, 2024

What

Previously we would only check if the import was present in a fix. Now, we are checking if import is accessible as the import we are looking for.

References

Fixes #458
Fixes #448

@eliottness eliottness force-pushed the eliottness/package-shadowing branch 2 times, most recently from 24d3523 to 6e5668a Compare December 11, 2024 15:18
@eliottness eliottness marked this pull request as ready for review December 11, 2024 15:19
@eliottness eliottness requested a review from a team as a code owner December 11, 2024 15:19
Signed-off-by: Eliott Bouhana <eliott.bouhana@datadoghq.com>
@eliottness eliottness force-pushed the eliottness/package-shadowing branch from 6e5668a to cb6d841 Compare December 11, 2024 15:20
Comment on lines +228 to +233
nodeChain := []dst.Node{c.node}
for p := c.NodeChain.parent; p != nil; p = p.parent {
nodeChain = append(nodeChain, p.node)
}

return c.refMap.AddImport(c.file, nodeChain, path, name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just pass the c.NodeChain? That would be equivalent, but incur fewer allocations? (Here you're basically copying a linked list into an array list...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because of circular imports :/

@@ -16,6 +16,7 @@ aspects:
}()

syntheticReferences:
github.com/go-chi/chi/v5: true
Copy link
Contributor

Choose a reason for hiding this comment

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

That reference exists in the original file, so it should be be reported as a synthetic one? It's not a big deal here (it'd be filtered later one due to it already being present in the importcfg file, but still...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is part of the idea to mitigate shadowing when dot imports are used

@RomainMuller RomainMuller added this pull request to the merge queue Dec 13, 2024
Merged via the queue into main with commit 4d4eb9b Dec 13, 2024
38 checks passed
@RomainMuller RomainMuller deleted the eliottness/package-shadowing branch December 13, 2024 13:43
Copy link

codecov bot commented Dec 13, 2024

Codecov Report

Attention: Patch coverage is 82.14286% with 10 lines in your changes missing coverage. Please review.

Project coverage is 63.96%. Comparing base (5e5d184) to head (cb6d841).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/injector/typed/refmap.go 76.31% 4 Missing and 5 partials ⚠️
internal/injector/check.go 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #463      +/-   ##
==========================================
+ Coverage   57.02%   63.96%   +6.94%     
==========================================
  Files         176      184       +8     
  Lines       10384    11084     +700     
==========================================
+ Hits         5921     7090    +1169     
+ Misses       4021     3461     -560     
- Partials      442      533      +91     
Components Coverage Δ
Generators 76.15% <ø> (+76.15%) ⬆️
Instruments 73.41% <ø> (+53.16%) ⬆️
Go Driver 78.62% <ø> (+12.90%) ⬆️
Toolexec Driver 74.28% <ø> (+2.09%) ⬆️
Aspects 78.75% <100.00%> (+8.94%) ⬆️
Injector 77.27% <82.14%> (+7.59%) ⬆️
Job Server 67.07% <ø> (+8.14%) ⬆️
Integration Test Suite 57.48% <ø> (+1.12%) ⬆️
Other 63.96% <82.14%> (+6.94%) ⬆️
Files with missing lines Coverage Δ
internal/injector/aspect/context/context.go 97.14% <100.00%> (+25.50%) ⬆️
internal/injector/injector.go 77.19% <100.00%> (ø)
internal/injector/check.go 83.33% <83.33%> (+3.33%) ⬆️
internal/injector/typed/refmap.go 84.90% <76.31%> (-4.57%) ⬇️

... and 53 files with indirect coverage changes

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.

[BUG] Unable to build against aws-xray-sdk-go package [BUG] SQL registration wrapper can shadow package name
2 participants