]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/fix: use reflect.TypeFor for known types
authorcui fliter <imcusg@gmail.com>
Wed, 2 Aug 2023 08:38:12 +0000 (16:38 +0800)
committerGopher Robot <gobot@golang.org>
Mon, 7 Aug 2023 00:25:49 +0000 (00:25 +0000)
For #60088

Change-Id: Id19435e864bcfd2adbb1492db3f8cdf2ee3c915e
Reviewed-on: https://go-review.googlesource.com/c/go/+/515175
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/cmd/fix/cftype.go

index e4988b1c625b0f4f7610e09dedb75de1c8cbb70c..d4fcc4485e5791b9c00725de145ea5bfe4845c28 100644 (file)
@@ -60,8 +60,8 @@ func typefix(f *ast.File, badType func(string) bool) bool {
        // There's no easy way to map from an ast.Expr to all the places that use them, so
        // we use reflect to find all such references.
        if len(badNils) > 0 {
-               exprType := reflect.TypeOf((*ast.Expr)(nil)).Elem()
-               exprSliceType := reflect.TypeOf(([]ast.Expr)(nil))
+               exprType := reflect.TypeFor[ast.Expr]()
+               exprSliceType := reflect.TypeFor[[]ast.Expr]()
                walk(f, func(n any) {
                        if n == nil {
                                return