mirror of
https://github.com/navidrome/navidrome.git
synced 2026-12-03 18:36:56 +00:00
fix(lint): check generic constraints before matching a ctx sibling
A sibling with a stricter constraint (FContext[T comparable] for F[T any]) was suggested even when the call's type argument does not satisfy it.
This commit is contained in:
1 parent
f8ed972e4c
commit
5794bacfeb
2 files changed
+14
-1
No files matched your search
@@ -127,7 +127,7 @@ func isDropIn(f, sib *types.Signature) bool {
|
||||
for i := range n {
|
||||
args[i] = f.TypeParams().At(i)
|
||||
}
|
||||
inst, err := types.Instantiate(nil, sib, args, false)
|
||||
inst, err := types.Instantiate(nil, sib, args, true)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
Vendored
+13
@@ -134,3 +134,16 @@ func irregular(c *http.Client) {
|
||||
var _ = describe("irregular", func() {
|
||||
_, _ = http.Head("/") // want `use net/http\.NewRequestWithContext with \(\*net/http\.Client\)\.Do and pass the caller's ctx`
|
||||
})
|
||||
|
||||
func Cmp[T any](v T) {}
|
||||
|
||||
func CmpContext[T comparable](ctx context.Context, v T) {}
|
||||
|
||||
func Loose[T comparable](v T) {}
|
||||
|
||||
func LooseContext[T any](ctx context.Context, v T) {}
|
||||
|
||||
func constraints() {
|
||||
Cmp([]int{1})
|
||||
Loose(1) // want `use a\.LooseContext and pass the caller's ctx`
|
||||
}
|
||||
Reference in new issue
Block a user