Commit 610657f
authored
fix(injector): preserve negated may matches (#857)
## Summary
- make `MatchType.Not` conservative for existential may-match results
- prevent negated receiver constraints from filtering an aspect before
AST matching
- add an injector regression fixture for `crypto/sha1.Sum` versus
`(*digest).Sum`
## Root cause
`may.Match` means that at least one node may match. Negating that result
as `NeverMatch` was unsound: a package can contain both a matching
receiver method and another function that satisfies the complete join
point. The early package filter therefore discarded the aspect before
node-level matching could distinguish them.
## Testing
- `go test -count=1 -run 'Test/function-body-negated-receiver$' -v
./internal/injector`\n- `GOPROXY=https://proxy.golang.org,direct go test
-race -shuffle=on -count=1 ./internal/injector/...`\n- `golangci-lint
run ./internal/injector/aspect/may/...
./internal/injector/aspect/join/... ./internal/injector/parse/...`\n-
`GOPROXY=https://proxy.golang.org,direct go build ./...`1 parent a2efd5a commit 610657f
3 files changed
Lines changed: 53 additions & 3 deletions
File tree
- internal/injector
- aspect/may
- testdata/injector/function-body-negated-receiver
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
0 commit comments