diff --git a/go.mod b/go.mod index 7df814138..3d45a9db0 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,8 @@ require ( require golang.org/x/sync v0.7.0 +require github.com/google/go-cmp v0.6.0 // indirect + require ( golang.org/x/sys v0.19.0 // indirect golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2 diff --git a/go.sum b/go.sum index 24ba39620..859945a95 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= diff --git a/internal/apidiff/apidiff.go b/internal/apidiff/apidiff.go index 087e112e5..f36f25cce 100644 --- a/internal/apidiff/apidiff.go +++ b/internal/apidiff/apidiff.go @@ -208,7 +208,8 @@ func (d *differ) typeChanged(obj types.Object, part string, old, new types.Type) // Since these can change without affecting compatibility, we don't want users to // be distracted by them, so we remove them. func removeNamesFromSignature(t types.Type) types.Type { - sig, ok := aliases.Unalias(t).(*types.Signature) + t = aliases.Unalias(t) + sig, ok := t.(*types.Signature) if !ok { return t } @@ -217,7 +218,7 @@ func removeNamesFromSignature(t types.Type) types.Type { var vars []*types.Var for i := 0; i < p.Len(); i++ { v := p.At(i) - vars = append(vars, types.NewVar(v.Pos(), v.Pkg(), "", v.Type())) + vars = append(vars, types.NewVar(v.Pos(), v.Pkg(), "", aliases.Unalias(v.Type()))) } return types.NewTuple(vars...) } diff --git a/internal/apidiff/apidiff_test.go b/internal/apidiff/apidiff_test.go index ecf32e4a2..2c8479667 100644 --- a/internal/apidiff/apidiff_test.go +++ b/internal/apidiff/apidiff_test.go @@ -10,11 +10,11 @@ import ( "go/types" "os" "path/filepath" - "reflect" "sort" "strings" "testing" + "github.com/google/go-cmp/cmp" "golang.org/x/tools/go/packages" "golang.org/x/tools/internal/testenv" ) @@ -42,12 +42,12 @@ func TestChanges(t *testing.T) { report := Changes(oldpkg.Types, newpkg.Types) got := report.messages(false) - if !reflect.DeepEqual(got, wanti) { - t.Errorf("incompatibles: got %v\nwant %v\n", got, wanti) + if diff := cmp.Diff(wanti, got); diff != "" { + t.Errorf("incompatibles (-want +got):\n%s", diff) } got = report.messages(true) - if !reflect.DeepEqual(got, wantc) { - t.Errorf("compatibles: got %v\nwant %v\n", got, wantc) + if diff := cmp.Diff(wantc, got); diff != "" { + t.Errorf("compatibles (-want +got):\n%s", diff) } }