@@ -199,7 +199,7 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
199199
200200 // extract AST information for all packages
201201 packages .Visit (pkgs , nil , func (pkg * packages.Package ) {
202- for root , _ := range wantedRoots {
202+ for root := range wantedRoots {
203203 pkgInfo := pkgInfos [pkg .PkgPath ]
204204 relDir , err := filepath .Rel (root , pkgInfo .PkgDir )
205205 if err != nil || noExtractRe .MatchString (relDir ) {
@@ -397,15 +397,15 @@ func extractObjects(tw *trap.Writer, scope *types.Scope, scopeLabel trap.Label)
397397 // do not appear as objects in any scope, so they have to be dealt
398398 // with separately in extractMethods.
399399 if funcObj , ok := obj .(* types.Func ); ok {
400- populateTypeParamParents (tw , funcObj .Type ().(* types.Signature ).TypeParams (), obj )
401- populateTypeParamParents (tw , funcObj .Type ().(* types.Signature ).RecvTypeParams (), obj )
400+ populateTypeParamParents (funcObj .Type ().(* types.Signature ).TypeParams (), obj )
401+ populateTypeParamParents (funcObj .Type ().(* types.Signature ).RecvTypeParams (), obj )
402402 }
403403 // Populate type parameter parents for named types. Note that we
404404 // skip type aliases as the original type should be the parent
405405 // of any type parameters.
406406 if typeNameObj , ok := obj .(* types.TypeName ); ok && ! typeNameObj .IsAlias () {
407407 if tp , ok := typeNameObj .Type ().(* types.Named ); ok {
408- populateTypeParamParents (tw , tp .TypeParams (), obj )
408+ populateTypeParamParents (tp .TypeParams (), obj )
409409 }
410410 }
411411 extractObject (tw , obj , lbl )
@@ -431,8 +431,8 @@ func extractMethod(tw *trap.Writer, meth *types.Func) trap.Label {
431431 if ! exists {
432432 // Populate type parameter parents for methods. They do not appear as
433433 // objects in any scope, so they have to be dealt with separately here.
434- populateTypeParamParents (tw , meth .Type ().(* types.Signature ).TypeParams (), meth )
435- populateTypeParamParents (tw , meth .Type ().(* types.Signature ).RecvTypeParams (), meth )
434+ populateTypeParamParents (meth .Type ().(* types.Signature ).TypeParams (), meth )
435+ populateTypeParamParents (meth .Type ().(* types.Signature ).RecvTypeParams (), meth )
436436 extractObject (tw , meth , methlbl )
437437 }
438438
@@ -490,7 +490,7 @@ func extractObject(tw *trap.Writer, obj types.Object, lbl trap.Label) {
490490func extractObjectTypes (tw * trap.Writer ) {
491491 // calling `extractType` on a named type will extract all methods defined
492492 // on it, which will add new objects. Therefore we need to do this first
493- // before we loops over all objects and emit them.
493+ // before we loop over all objects and emit them.
494494 changed := true
495495 for changed {
496496 changed = tw .ForEachObject (extractObjectType )
@@ -1129,11 +1129,9 @@ func extractExpr(tw *trap.Writer, expr ast.Expr, parent trap.Label, idx int) {
11291129// each child over its preceding child (usually either 1 for assigning increasing indices, or
11301130// -1 for decreasing indices)
11311131func extractExprs (tw * trap.Writer , exprs []ast.Expr , parent trap.Label , idx int , dir int ) {
1132- if exprs != nil {
1133- for _ , expr := range exprs {
1134- extractExpr (tw , expr , parent , idx )
1135- idx += dir
1136- }
1132+ for _ , expr := range exprs {
1133+ extractExpr (tw , expr , parent , idx )
1134+ idx += dir
11371135 }
11381136}
11391137
@@ -1389,13 +1387,10 @@ func extractStmt(tw *trap.Writer, stmt ast.Stmt, parent trap.Label, idx int) {
13891387// each child over its preceding child (usually either 1 for assigning increasing indices, or
13901388// -1 for decreasing indices)
13911389func extractStmts (tw * trap.Writer , stmts []ast.Stmt , parent trap.Label , idx int , dir int ) {
1392- if stmts != nil {
1393- for _ , stmt := range stmts {
1394- extractStmt (tw , stmt , parent , idx )
1395- idx += dir
1396- }
1390+ for _ , stmt := range stmts {
1391+ extractStmt (tw , stmt , parent , idx )
1392+ idx += dir
13971393 }
1398-
13991394}
14001395
14011396// extractDecl extracts AST information for the given declaration
@@ -1944,7 +1939,7 @@ func extractTypeParamDecls(tw *trap.Writer, fields *ast.FieldList, parent trap.L
19441939}
19451940
19461941// populateTypeParamParents sets `parent` as the parent of the elements of `typeparams`
1947- func populateTypeParamParents (tw * trap. Writer , typeparams * types.TypeParamList , parent types.Object ) {
1942+ func populateTypeParamParents (typeparams * types.TypeParamList , parent types.Object ) {
19481943 if typeparams != nil {
19491944 for idx := 0 ; idx < typeparams .Len (); idx ++ {
19501945 setTypeParamParent (typeparams .At (idx ), parent )
@@ -1966,16 +1961,6 @@ func getObjectBeingUsed(tw *trap.Writer, ident *ast.Ident) types.Object {
19661961 }
19671962}
19681963
1969- // tryGetGenericType returns the generic type of `tp`, and a boolean indicating
1970- // whether it is the same as `tp`.
1971- func tryGetGenericType (tp types.Type ) (* types.Named , bool ) {
1972- if namedType , ok := tp .(* types.Named ); ok {
1973- originType := namedType .Origin ()
1974- return originType , namedType == originType
1975- }
1976- return nil , false
1977- }
1978-
19791964// trackInstantiatedStructFields tries to give the fields of an instantiated
19801965// struct type underlying `tp` the same labels as the corresponding fields of
19811966// the generic struct type. This is so that when we come across the
0 commit comments