зеркало из https://github.com/golang/tools.git
internal/apidiff: support materialized aliases
(The previous CL 559935 was insufficient.) Also, improve test output. Updates golang/go#65294 Change-Id: I05cafadce0dd6f18ff66d2ca462a3eb546c4ca81 Reviewed-on: https://go-review.googlesource.com/c/tools/+/577576 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Родитель
3520955d2d
Коммит
b4b81864a1
2
go.mod
2
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
|
||||
|
|
2
go.sum
2
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=
|
||||
|
|
|
@ -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...)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче