@@ -3,8 +3,6 @@ package astcopy
33
44import (
55 "go/ast"
6-
7- "golang.org/x/exp/typeparams"
86)
97
108// Node returns x node deep copy.
@@ -198,7 +196,7 @@ func IndexExpr(x *ast.IndexExpr) *ast.IndexExpr {
198196
199197// IndexListExpr returns x deep copy.
200198// Copy of nil argument is nil.
201- func IndexListExpr (x * typeparams .IndexListExpr ) * typeparams .IndexListExpr {
199+ func IndexListExpr (x * ast .IndexListExpr ) * ast .IndexListExpr {
202200 if x == nil {
203201 return nil
204202 }
@@ -787,6 +785,34 @@ func FuncDecl(x *ast.FuncDecl) *ast.FuncDecl {
787785 return & cp
788786}
789787
788+ // FuncType returns x deep copy.
789+ // Copy of nil argument is nil.
790+ func FuncType (x * ast.FuncType ) * ast.FuncType {
791+ if x == nil {
792+ return nil
793+ }
794+ cp := * x
795+ cp .Params = FieldList (x .Params )
796+ cp .Results = FieldList (x .Results )
797+ cp .TypeParams = FieldList (x .TypeParams )
798+ return & cp
799+ }
800+
801+ // TypeSpec returns x deep copy.
802+ // Copy of nil argument is nil.
803+ func TypeSpec (x * ast.TypeSpec ) * ast.TypeSpec {
804+ if x == nil {
805+ return nil
806+ }
807+ cp := * x
808+ cp .Name = Ident (x .Name )
809+ cp .Type = copyExpr (x .Type )
810+ cp .Doc = CommentGroup (x .Doc )
811+ cp .Comment = CommentGroup (x .Comment )
812+ cp .TypeParams = FieldList (x .TypeParams )
813+ return & cp
814+ }
815+
790816func copyNode (x ast.Node ) ast.Node {
791817 switch x := x .(type ) {
792818 case ast.Expr :
@@ -838,7 +864,7 @@ func copyExpr(x ast.Expr) ast.Expr {
838864 return SelectorExpr (x )
839865 case * ast.IndexExpr :
840866 return IndexExpr (x )
841- case * typeparams .IndexListExpr :
867+ case * ast .IndexListExpr :
842868 return IndexListExpr (x )
843869 case * ast.SliceExpr :
844870 return SliceExpr (x )
0 commit comments