File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ package astcopy
33
44import (
55 "go/ast"
6+
7+ "golang.org/x/exp/typeparams"
68)
79
810// Node returns x node deep copy.
@@ -341,6 +343,9 @@ func FuncType(x *ast.FuncType) *ast.FuncType {
341343 cp := * x
342344 cp .Params = FieldList (x .Params )
343345 cp .Results = FieldList (x .Results )
346+ if typeParams := typeparams .ForFuncType (x ); typeParams != nil {
347+ * typeparams .ForFuncType (& cp ) = * FieldList (typeParams )
348+ }
344349 return & cp
345350}
346351
@@ -429,6 +434,9 @@ func TypeSpec(x *ast.TypeSpec) *ast.TypeSpec {
429434 cp .Type = copyExpr (x .Type )
430435 cp .Doc = CommentGroup (x .Doc )
431436 cp .Comment = CommentGroup (x .Comment )
437+ if typeParams := typeparams .ForTypeSpec (x ); typeParams != nil {
438+ * typeparams .ForTypeSpec (& cp ) = * FieldList (typeParams )
439+ }
432440 return & cp
433441}
434442
Original file line number Diff line number Diff line change 11module github.com/go-toolsmith/astcopy
22
3+ go 1.16
4+
35require (
4- github.com/go-toolsmith/astequal v1.0.0
6+ github.com/go-toolsmith/astequal v1.0.2
57 github.com/go-toolsmith/strparse v1.0.0
8+ golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171
69)
Original file line number Diff line number Diff line change 1- github.com/go-toolsmith/astequal v1.0.0 h1:4zxD8j3JRFNyLN46lodQuqz3xdKSrur7U/sr0SDS/gQ =
2- github.com/go-toolsmith/astequal v1.0.0 /go.mod h1:H+xSiq0+LtiDC11+h1G32h7Of5O3CYFJ99GVbS5lDKY =
1+ github.com/go-toolsmith/astequal v1.0.2 h1:+XvaV8zNxua+9+Oa4AHmgmpo4RYAbwr/qjNppLfX2yM =
2+ github.com/go-toolsmith/astequal v1.0.2 /go.mod h1:9Ai4UglvtR+4up+bAD4+hCj7iTo4m/OXVTSLnCyTAx4 =
33github.com/go-toolsmith/strparse v1.0.0 h1:Vcw78DnpCAKlM20kSbAyO4mPfJn/lyYA4BJUDxe2Jb4 =
44github.com/go-toolsmith/strparse v1.0.0 /go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8 =
5+ golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171 h1:DZhP7zSquENyG3Yb6ZpGqNEtgE8dfXhcLcheIF9RQHY =
6+ golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171 /go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk =
You can’t perform that action at this time.
0 commit comments