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:
Deluan committed 2026-11-17 20:21:59 -05:00
1 parent f8ed972e4c
commit 5794bacfeb
2 files changed
+14 -1

No files matched your search

+1 -1
View File
@@ -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
}
+13
View File
@@ -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`
}