File tree Expand file tree Collapse file tree 8 files changed +20
-20
lines changed
analysisinternal/generated Expand file tree Collapse file tree 8 files changed +20
-20
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ var Analyzer = &analysis.Analyzer{
4141 URL : "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/pkgfact" ,
4242 Run : run ,
4343 FactTypes : []analysis.Fact {new (pairsFact )},
44- ResultType : reflect .TypeOf ( map [string ]string {} ),
44+ ResultType : reflect .TypeFor [ map [string ]string ]( ),
4545}
4646
4747// A pairsFact is a package-level fact that records
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ var Analyzer = &analysis.Analyzer{
4343 URL : "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/printf" ,
4444 Requires : []* analysis.Analyzer {inspect .Analyzer },
4545 Run : run ,
46- ResultType : reflect .TypeOf (( * Result )( nil ) ),
46+ ResultType : reflect .TypeFor [ * Result ]( ),
4747 FactTypes : []analysis.Fact {new (isWrapper )},
4848}
4949
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ var Analyzer = &analysis.Analyzer{
2424 URL : "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/usesgenerics" ,
2525 Requires : []* analysis.Analyzer {inspect .Analyzer },
2626 Run : run ,
27- ResultType : reflect .TypeOf (( * Result )( nil ) ),
27+ ResultType : reflect .TypeFor [ * Result ]( ),
2828 FactTypes : []analysis.Fact {new (featuresFact )},
2929}
3030
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ var Analyzer = &analysis.Analyzer{
1818 Name : "generated" ,
1919 Doc : "detect which Go files are generated" ,
2020 URL : "https://pkg.go.dev/golang.org/x/tools/internal/analysisinternal/generated" ,
21- ResultType : reflect .TypeOf (( * Result )( nil ) ),
21+ ResultType : reflect .TypeFor [ * Result ]( ),
2222 Run : func (pass * analysis.Pass ) (any , error ) {
2323 set := make (map [* token.File ]bool )
2424 for _ , file := range pass .Files {
Original file line number Diff line number Diff line change @@ -461,7 +461,7 @@ func TestFactFilter(t *testing.T) {
461461 s .ExportPackageFact (& otherFact {"bad package fact" })
462462
463463 filter := map [reflect.Type ]bool {
464- reflect .TypeOf ( & myFact {} ): true ,
464+ reflect .TypeFor [ * myFact ]( ): true ,
465465 }
466466
467467 pkgFacts := s .AllPackageFacts (filter )
Original file line number Diff line number Diff line change @@ -228,14 +228,14 @@ func (e *Exported) getMarkers() error {
228228}
229229
230230var (
231- noteType = reflect .TypeOf (( * expect .Note )( nil ) )
232- identifierType = reflect .TypeOf ( expect .Identifier ( "" ) )
233- posType = reflect .TypeOf ( token .Pos ( 0 ) )
234- positionType = reflect .TypeOf ( token.Position {} )
235- rangeType = reflect .TypeOf ( Range {} )
236- fsetType = reflect .TypeOf (( * token .FileSet )( nil ) )
237- regexType = reflect .TypeOf (( * regexp .Regexp )( nil ) )
238- exportedType = reflect .TypeOf (( * Exported )( nil ) )
231+ noteType = reflect .TypeFor [ * expect.Note ]( )
232+ identifierType = reflect .TypeFor [ expect.Identifier ]( )
233+ posType = reflect .TypeFor [ token.Pos ]( )
234+ positionType = reflect .TypeFor [ token.Position ]( )
235+ rangeType = reflect .TypeFor [ Range ]( )
236+ fsetType = reflect .TypeFor [ * token.FileSet ]( )
237+ regexType = reflect .TypeFor [ * regexp.Regexp ]( )
238+ exportedType = reflect .TypeFor [ * Exported ]( )
239239)
240240
241241// converter converts from a marker's argument parsed from the comment to
Original file line number Diff line number Diff line change @@ -3139,7 +3139,7 @@ func cleanNodes[T ast.Node](nodes []T) []T {
31393139//
31403140// TODO(adonovan): remove this horrendous workaround when #20744 is finally fixed.
31413141func clearPositions (root ast.Node ) {
3142- posType := reflect .TypeOf ( token .NoPos )
3142+ posType := reflect .TypeFor [ token.Pos ]( )
31433143 ast .Inspect (root , func (n ast.Node ) bool {
31443144 if n != nil {
31453145 v := reflect .ValueOf (n ).Elem () // deref the pointer to struct
Original file line number Diff line number Diff line change @@ -158,12 +158,12 @@ var (
158158 objectPtrNil = reflect .ValueOf ((* ast .Object )(nil ))
159159 scopePtrNil = reflect .ValueOf ((* ast .Scope )(nil ))
160160
161- identType = reflect .TypeOf (( * ast .Ident )( nil ) )
162- selectorExprType = reflect .TypeOf (( * ast .SelectorExpr )( nil ) )
163- objectPtrType = reflect .TypeOf (( * ast .Object )( nil ) )
164- statementType = reflect .TypeOf (( * ast .Stmt )( nil )). Elem ()
165- positionType = reflect .TypeOf ( token .NoPos )
166- scopePtrType = reflect .TypeOf (( * ast .Scope )( nil ) )
161+ identType = reflect .TypeFor [ * ast.Ident ]( )
162+ selectorExprType = reflect .TypeFor [ * ast.SelectorExpr ]( )
163+ objectPtrType = reflect .TypeFor [ * ast.Object ]( )
164+ statementType = reflect .TypeFor [ ast.Stmt ] ()
165+ positionType = reflect .TypeFor [ token.Pos ]( )
166+ scopePtrType = reflect .TypeFor [ * ast.Scope ]( )
167167)
168168
169169// apply replaces each AST field x in val with f(x), returning val.
You can’t perform that action at this time.
0 commit comments