From: cui fliter Date: Wed, 2 Aug 2023 08:38:12 +0000 (+0800) Subject: cmd/fix: use reflect.TypeFor for known types X-Git-Tag: go1.22rc1~1401 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2d2662f8d0b50d123da2f6674308cf5e0c21e062;p=gostls13.git cmd/fix: use reflect.TypeFor for known types For #60088 Change-Id: Id19435e864bcfd2adbb1492db3f8cdf2ee3c915e Reviewed-on: https://go-review.googlesource.com/c/go/+/515175 Auto-Submit: Ian Lance Taylor Run-TryBot: shuang cui Run-TryBot: Ian Lance Taylor Reviewed-by: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Michael Knyszek --- diff --git a/src/cmd/fix/cftype.go b/src/cmd/fix/cftype.go index e4988b1c62..d4fcc4485e 100644 --- a/src/cmd/fix/cftype.go +++ b/src/cmd/fix/cftype.go @@ -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