From 2d2662f8d0b50d123da2f6674308cf5e0c21e062 Mon Sep 17 00:00:00 2001 From: cui fliter Date: Wed, 2 Aug 2023 16:38:12 +0800 Subject: [PATCH] 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 --- src/cmd/fix/cftype.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 -- 2.50.0