Skip to content

Commit

Permalink
Revert "Adjust for reflect.Type.NumMethod change in Go1.16 (#240)" (#242
Browse files Browse the repository at this point in the history
)

This reverts commit ab46b8b.
The upstream change in Go1.16 has been rolled back.
See golang/go#42123
  • Loading branch information
dsnet authored Nov 12, 2020
1 parent ab46b8b commit d3c8501
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 55 deletions.
3 changes: 1 addition & 2 deletions cmp/cmpopts/ignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/internal/function"
"github.com/google/go-cmp/cmp/internal/value"
)

// IgnoreFields returns an Option that ignores fields of the
Expand Down Expand Up @@ -83,7 +82,7 @@ func newIfaceFilter(ifaces interface{}) (tf ifaceFilter) {
panic("struct cannot have named fields")
case fi.Type.Kind() != reflect.Interface:
panic("embedded field must be an interface type")
case value.IsEmptyInterface(fi.Type):
case fi.Type.NumMethod() == 0:
// This matches everything; why would you ever want this?
panic("cannot ignore empty interface")
default:
Expand Down
14 changes: 0 additions & 14 deletions cmp/internal/value/iface.go

This file was deleted.

35 changes: 0 additions & 35 deletions cmp/internal/value/iface_test.go

This file was deleted.

7 changes: 3 additions & 4 deletions cmp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"strings"

"github.com/google/go-cmp/cmp/internal/function"
"github.com/google/go-cmp/cmp/internal/value"
)

// Option configures for specific behavior of Equal and Diff. In particular,
Expand Down Expand Up @@ -162,7 +161,7 @@ func FilterValues(f interface{}, opt Option) Option {
}
if opt := normalizeOption(opt); opt != nil {
vf := &valuesFilter{fnc: v, opt: opt}
if ti := v.Type().In(0); !value.IsEmptyInterface(ti) {
if ti := v.Type().In(0); ti.Kind() != reflect.Interface || ti.NumMethod() > 0 {
vf.typ = ti
}
return vf
Expand Down Expand Up @@ -287,7 +286,7 @@ func Transformer(name string, f interface{}) Option {
panic(fmt.Sprintf("invalid name: %q", name))
}
tr := &transformer{name: name, fnc: reflect.ValueOf(f)}
if ti := v.Type().In(0); !value.IsEmptyInterface(ti) {
if ti := v.Type().In(0); ti.Kind() != reflect.Interface || ti.NumMethod() > 0 {
tr.typ = ti
}
return tr
Expand Down Expand Up @@ -346,7 +345,7 @@ func Comparer(f interface{}) Option {
panic(fmt.Sprintf("invalid comparer function: %T", f))
}
cm := &comparer{fnc: v}
if ti := v.Type().In(0); !value.IsEmptyInterface(ti) {
if ti := v.Type().In(0); ti.Kind() != reflect.Interface || ti.NumMethod() > 0 {
cm.typ = ti
}
return cm
Expand Down

0 comments on commit d3c8501

Please sign in to comment.