Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Go 1.18 #11

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions astcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package astcopy

import (
"go/ast"

"golang.org/x/exp/typeparams"
)

// Node returns x node deep copy.
Expand Down Expand Up @@ -198,7 +196,7 @@ func IndexExpr(x *ast.IndexExpr) *ast.IndexExpr {

// IndexListExpr returns x deep copy.
// Copy of nil argument is nil.
func IndexListExpr(x *typeparams.IndexListExpr) *typeparams.IndexListExpr {
func IndexListExpr(x *ast.IndexListExpr) *ast.IndexListExpr {
if x == nil {
return nil
}
Expand Down Expand Up @@ -787,6 +785,34 @@ func FuncDecl(x *ast.FuncDecl) *ast.FuncDecl {
return &cp
}

// FuncType returns x deep copy.
// Copy of nil argument is nil.
func FuncType(x *ast.FuncType) *ast.FuncType {
if x == nil {
return nil
}
cp := *x
cp.Params = FieldList(x.Params)
cp.Results = FieldList(x.Results)
cp.TypeParams = FieldList(x.TypeParams)
return &cp
}

// TypeSpec returns x deep copy.
// Copy of nil argument is nil.
func TypeSpec(x *ast.TypeSpec) *ast.TypeSpec {
if x == nil {
return nil
}
cp := *x
cp.Name = Ident(x.Name)
cp.Type = copyExpr(x.Type)
cp.Doc = CommentGroup(x.Doc)
cp.Comment = CommentGroup(x.Comment)
cp.TypeParams = FieldList(x.TypeParams)
return &cp
}

func copyNode(x ast.Node) ast.Node {
switch x := x.(type) {
case ast.Expr:
Expand Down Expand Up @@ -838,7 +864,7 @@ func copyExpr(x ast.Expr) ast.Expr {
return SelectorExpr(x)
case *ast.IndexExpr:
return IndexExpr(x)
case *typeparams.IndexListExpr:
case *ast.IndexListExpr:
return IndexListExpr(x)
case *ast.SliceExpr:
return SliceExpr(x)
Expand Down
30 changes: 0 additions & 30 deletions astcopy_go117.go

This file was deleted.

36 changes: 0 additions & 36 deletions astcopy_go118.go

This file was deleted.

7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module github.com/go-toolsmith/astcopy

go 1.16
go 1.18

require (
github.com/go-toolsmith/astequal v1.1.0
github.com/go-toolsmith/astequal v1.2.0
github.com/go-toolsmith/strparse v1.1.0
golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9
)

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