Skip to content

Commit 72fdfa6

Browse files
committed
gopls/internal/golang: Disable test generation for generic functions
For golang/vscode-go#1594 Change-Id: I8563e4cde1606a23a402bc2154b1af69cb9ff724 Reviewed-on: https://go-review.googlesource.com/c/tools/+/632857 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent b80f1ed commit 72fdfa6

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

gopls/internal/golang/codeaction.go

+5
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,11 @@ func addTest(ctx context.Context, req *codeActionsRequest) error {
504504
return nil
505505
}
506506

507+
// TODO(hxjiang): support functions with type parameter.
508+
if decl.Type.TypeParams != nil {
509+
return nil
510+
}
511+
507512
cmd := command.NewAddTestCommand("Add test for "+decl.Name.String(), req.loc)
508513
req.addCommandAction(cmd, true)
509514

gopls/internal/test/marker/testdata/codeaction/addtest.txt

+10
Original file line numberDiff line numberDiff line change
@@ -1530,3 +1530,13 @@ var local renamedctx.Context
15301530
+ })
15311531
+ }
15321532
+}
1533+
-- typeparameter/typeparameter.go --
1534+
package main
1535+
1536+
func Function[T any] () {} // no suggested fix
1537+
1538+
type Foo struct {}
1539+
1540+
func NewFoo()
1541+
1542+
func (*Foo) Method[T any]() {} // no suggested fix

0 commit comments

Comments
 (0)