diff --git a/go/analysis/passes/stdmethods/stdmethods.go b/go/analysis/passes/stdmethods/stdmethods.go index 83495112..72530a0e 100644 --- a/go/analysis/passes/stdmethods/stdmethods.go +++ b/go/analysis/passes/stdmethods/stdmethods.go @@ -8,7 +8,6 @@ package stdmethods import ( "go/ast" - "go/token" "go/types" "strings" @@ -163,7 +162,7 @@ func matchParams(pass *analysis.Pass, expect []string, actual *types.Tuple, pref if i >= actual.Len() { return false } - if !matchParamType(pass.Fset, pass.Pkg, x, actual.At(i).Type()) { + if !matchParamType(x, actual.At(i).Type()) { return false } } @@ -174,13 +173,8 @@ func matchParams(pass *analysis.Pass, expect []string, actual *types.Tuple, pref } // Does this one type match? -func matchParamType(fset *token.FileSet, pkg *types.Package, expect string, actual types.Type) bool { +func matchParamType(expect string, actual types.Type) bool { expect = strings.TrimPrefix(expect, "=") - // Strip package name if we're in that package. - if n := len(pkg.Name()); len(expect) > n && expect[:n] == pkg.Name() && expect[n] == '.' { - expect = expect[n+1:] - } - // Overkill but easy. return typeString(actual) == expect } diff --git a/go/analysis/passes/stdmethods/stdmethods_test.go b/go/analysis/passes/stdmethods/stdmethods_test.go index fe4fe53c..60b1a53c 100644 --- a/go/analysis/passes/stdmethods/stdmethods_test.go +++ b/go/analysis/passes/stdmethods/stdmethods_test.go @@ -15,3 +15,7 @@ func Test(t *testing.T) { testdata := analysistest.TestData() analysistest.Run(t, testdata, stdmethods.Analyzer, "a") } + +func TestAnalyzeEncodingXML(t *testing.T) { + analysistest.Run(t, "", stdmethods.Analyzer, "encoding/xml") +}