Skip to content

Commit 2391511

Browse files
authored
Update to Go 1.18 (#21)
1 parent 84b0b16 commit 2391511

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

astequal.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ package astequal
44
import (
55
"go/ast"
66
"go/token"
7-
8-
"golang.org/x/exp/typeparams"
97
)
108

119
// Node reports whether two AST nodes are structurally (deep) equal.
@@ -109,8 +107,8 @@ func astExprEq(x, y ast.Expr) bool {
109107
y, ok := y.(*ast.IndexExpr)
110108
return ok && astIndexExprEq(x, y)
111109

112-
case *typeparams.IndexListExpr:
113-
y, ok := y.(*typeparams.IndexListExpr)
110+
case *ast.IndexListExpr:
111+
y, ok := y.(*ast.IndexListExpr)
114112
return ok && astIndexListExprEq(x, y)
115113

116114
case *ast.SliceExpr:
@@ -323,7 +321,7 @@ func astFuncTypeEq(x, y *ast.FuncType) bool {
323321
}
324322
return astFieldListEq(x.Params, y.Params) &&
325323
astFieldListEq(x.Results, y.Results) &&
326-
astFieldListEq(typeparams.ForFuncType(x), typeparams.ForFuncType(y))
324+
astFieldListEq(forFuncType(x), forFuncType(y))
327325
}
328326

329327
func astBasicLitEq(x, y *ast.BasicLit) bool {
@@ -378,7 +376,7 @@ func astIndexExprEq(x, y *ast.IndexExpr) bool {
378376
return astExprEq(x.X, y.X) && astExprEq(x.Index, y.Index)
379377
}
380378

381-
func astIndexListExprEq(x, y *typeparams.IndexListExpr) bool {
379+
func astIndexListExprEq(x, y *ast.IndexListExpr) bool {
382380
if x == nil || y == nil {
383381
return x == y
384382
}
@@ -690,7 +688,7 @@ func astTypeSpecEq(x, y *ast.TypeSpec) bool {
690688
return x == y
691689
}
692690
return astIdentEq(x.Name, y.Name) && astExprEq(x.Type, y.Type) &&
693-
astFieldListEq(typeparams.ForTypeSpec(x), typeparams.ForTypeSpec(y))
691+
astFieldListEq(forTypeSpec(x), forTypeSpec(y))
694692
}
695693

696694
func astValueSpecEq(x, y *ast.ValueSpec) bool {
@@ -755,3 +753,19 @@ func astExprSliceEq(xs, ys []ast.Expr) bool {
755753
}
756754
return true
757755
}
756+
757+
// forTypeSpec returns n.TypeParams.
758+
func forTypeSpec(n *ast.TypeSpec) *ast.FieldList {
759+
if n == nil {
760+
return nil
761+
}
762+
return n.TypeParams
763+
}
764+
765+
// forFuncType returns n.TypeParams.
766+
func forFuncType(n *ast.FuncType) *ast.FieldList {
767+
if n == nil {
768+
return nil
769+
}
770+
return n.TypeParams
771+
}

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
module github.com/go-toolsmith/astequal
22

3-
go 1.16
3+
go 1.18
44

55
require (
66
github.com/go-toolsmith/strparse v1.1.0
77
github.com/google/go-cmp v0.6.0
8-
golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9
98
)

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@ github.com/go-toolsmith/strparse v1.1.0/go.mod h1:7ksGy58fsaQkGQlY8WVoBFNyEPMGuJ
55
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
66
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
77
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)