Skip to content

Commit 7f80389

Browse files
committed
go/analysis/passes/stringintconv: audit for types.Alias safety
Updates golang/go#65294 Change-Id: Idfb583f0d3ad3753b770946cb9b9360625670d0d Reviewed-on: https://go-review.googlesource.com/c/tools/+/559917 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Tim King <[email protected]>
1 parent 76795ef commit 7f80389

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

go/analysis/passes/stringintconv/string.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"golang.org/x/tools/go/analysis/passes/inspect"
1616
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
1717
"golang.org/x/tools/go/ast/inspector"
18+
"golang.org/x/tools/internal/aliases"
1819
"golang.org/x/tools/internal/typeparams"
1920
)
2021

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

195196
func structuralTypes(t types.Type) ([]types.Type, error) {
196197
var structuralTypes []types.Type
197-
switch t := t.(type) {
198-
case *types.TypeParam:
199-
terms, err := typeparams.StructuralTerms(t)
198+
if tp, ok := aliases.Unalias(t).(*types.TypeParam); ok {
199+
terms, err := typeparams.StructuralTerms(tp)
200200
if err != nil {
201201
return nil, err
202202
}
203203
for _, term := range terms {
204204
structuralTypes = append(structuralTypes, term.Type())
205205
}
206-
default:
206+
} else {
207207
structuralTypes = append(structuralTypes, t)
208208
}
209209
return structuralTypes, nil

0 commit comments

Comments
 (0)