Skip to content

Commit

Permalink
go/analysis/passes/stringintconv: audit for types.Alias safety
Browse files Browse the repository at this point in the history
Updates golang/go#65294

Change-Id: Idfb583f0d3ad3753b770946cb9b9360625670d0d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/559917
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
  • Loading branch information
adonovan committed Feb 7, 2024
1 parent 76795ef commit 7f80389
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions go/analysis/passes/stringintconv/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
"golang.org/x/tools/go/ast/inspector"
"golang.org/x/tools/internal/aliases"
"golang.org/x/tools/internal/typeparams"
)

Expand Down Expand Up @@ -194,16 +195,15 @@ func run(pass *analysis.Pass) (interface{}, error) {

func structuralTypes(t types.Type) ([]types.Type, error) {
var structuralTypes []types.Type
switch t := t.(type) {
case *types.TypeParam:
terms, err := typeparams.StructuralTerms(t)
if tp, ok := aliases.Unalias(t).(*types.TypeParam); ok {
terms, err := typeparams.StructuralTerms(tp)
if err != nil {
return nil, err
}
for _, term := range terms {
structuralTypes = append(structuralTypes, term.Type())
}
default:
} else {
structuralTypes = append(structuralTypes, t)
}
return structuralTypes, nil
Expand Down

0 comments on commit 7f80389

Please sign in to comment.