Skip to content

Commit 07015e1

Browse files
committed
Revert "Adjust for reflect.Type.NumMethod change in Go1.16 (#240)"
This reverts commit ab46b8b. The upstream change in Go1.16 has been rolled back. See golang/go#42123
1 parent ab46b8b commit 07015e1

File tree

4 files changed

+4
-55
lines changed

4 files changed

+4
-55
lines changed

cmp/cmpopts/ignore.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212

1313
"github.com/google/go-cmp/cmp"
1414
"github.com/google/go-cmp/cmp/internal/function"
15-
"github.com/google/go-cmp/cmp/internal/value"
1615
)
1716

1817
// IgnoreFields returns an Option that ignores fields of the
@@ -83,7 +82,7 @@ func newIfaceFilter(ifaces interface{}) (tf ifaceFilter) {
8382
panic("struct cannot have named fields")
8483
case fi.Type.Kind() != reflect.Interface:
8584
panic("embedded field must be an interface type")
86-
case value.IsEmptyInterface(fi.Type):
85+
case fi.Type.NumMethod() == 0:
8786
// This matches everything; why would you ever want this?
8887
panic("cannot ignore empty interface")
8988
default:

cmp/internal/value/iface.go

Lines changed: 0 additions & 14 deletions
This file was deleted.

cmp/internal/value/iface_test.go

Lines changed: 0 additions & 35 deletions
This file was deleted.

cmp/options.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"strings"
1212

1313
"github.com/google/go-cmp/cmp/internal/function"
14-
"github.com/google/go-cmp/cmp/internal/value"
1514
)
1615

1716
// Option configures for specific behavior of Equal and Diff. In particular,
@@ -162,7 +161,7 @@ func FilterValues(f interface{}, opt Option) Option {
162161
}
163162
if opt := normalizeOption(opt); opt != nil {
164163
vf := &valuesFilter{fnc: v, opt: opt}
165-
if ti := v.Type().In(0); !value.IsEmptyInterface(ti) {
164+
if ti := v.Type().In(0); ti.Kind() != reflect.Interface || ti.NumMethod() > 0 {
166165
vf.typ = ti
167166
}
168167
return vf
@@ -287,7 +286,7 @@ func Transformer(name string, f interface{}) Option {
287286
panic(fmt.Sprintf("invalid name: %q", name))
288287
}
289288
tr := &transformer{name: name, fnc: reflect.ValueOf(f)}
290-
if ti := v.Type().In(0); !value.IsEmptyInterface(ti) {
289+
if ti := v.Type().In(0); ti.Kind() != reflect.Interface || ti.NumMethod() > 0 {
291290
tr.typ = ti
292291
}
293292
return tr
@@ -346,7 +345,7 @@ func Comparer(f interface{}) Option {
346345
panic(fmt.Sprintf("invalid comparer function: %T", f))
347346
}
348347
cm := &comparer{fnc: v}
349-
if ti := v.Type().In(0); !value.IsEmptyInterface(ti) {
348+
if ti := v.Type().In(0); ti.Kind() != reflect.Interface || ti.NumMethod() > 0 {
350349
cm.typ = ti
351350
}
352351
return cm

0 commit comments

Comments
 (0)