Skip to content

Commit c6b07b9

Browse files
authored
Update to Go 1.18 (#11)
1 parent 71b452a commit c6b07b9

File tree

5 files changed

+38
-77
lines changed

5 files changed

+38
-77
lines changed

astcopy.go

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package astcopy
33

44
import (
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+
790816
func 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)

astcopy_go117.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

astcopy_go118.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
module github.com/go-toolsmith/astcopy
22

3-
go 1.16
3+
go 1.18
44

55
require (
6-
github.com/go-toolsmith/astequal v1.1.0
6+
github.com/go-toolsmith/astequal v1.2.0
77
github.com/go-toolsmith/strparse v1.1.0
8-
golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9
98
)
9+
10+
require github.com/google/go-cmp v0.6.0 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
github.com/go-toolsmith/astequal v1.0.3/go.mod h1:9Ai4UglvtR+4up+bAD4+hCj7iTo4m/OXVTSLnCyTAx4=
2-
github.com/go-toolsmith/astequal v1.1.0 h1:kHKm1AWqClYn15R0K1KKE4RG614D46n+nqUQ06E1dTw=
3-
github.com/go-toolsmith/astequal v1.1.0/go.mod h1:sedf7VIdCL22LD8qIvv7Nn9MuWJruQA/ysswh64lffQ=
2+
github.com/go-toolsmith/astequal v1.2.0 h1:3Fs3CYZ1k9Vo4FzFhwwewC3CHISHDnVUPC4x0bI2+Cw=
3+
github.com/go-toolsmith/astequal v1.2.0/go.mod h1:c8NZ3+kSFtFY/8lPso4v8LuJjdJiUFVnSuU3s0qrrDY=
44
github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8=
55
github.com/go-toolsmith/strparse v1.1.0 h1:GAioeZUK9TGxnLS+qfdqNbA4z0SSm5zVNtCQiyP2Bvw=
66
github.com/go-toolsmith/strparse v1.1.0/go.mod h1:7ksGy58fsaQkGQlY8WVoBFNyEPMGuJin1rfoPS4lBSQ=
7+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
8+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
79
golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
8-
golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9 h1:6WHiuFL9FNjg8RljAaT7FNUuKDbvMqS1i5cr2OE2sLQ=
9-
golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=

0 commit comments

Comments
 (0)