|
@@ -36,7 +36,6 @@ import (
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
"github.com/google/go-cmp/cmp/internal/diff"
|
|
"github.com/google/go-cmp/cmp/internal/diff"
|
|
- "github.com/google/go-cmp/cmp/internal/flags"
|
|
|
|
"github.com/google/go-cmp/cmp/internal/function"
|
|
"github.com/google/go-cmp/cmp/internal/function"
|
|
"github.com/google/go-cmp/cmp/internal/value"
|
|
"github.com/google/go-cmp/cmp/internal/value"
|
|
)
|
|
)
|
|
@@ -319,7 +318,6 @@ func (s *state) tryMethod(t reflect.Type, vx, vy reflect.Value) bool {
|
|
}
|
|
}
|
|
|
|
|
|
func (s *state) callTRFunc(f, v reflect.Value, step Transform) reflect.Value {
|
|
func (s *state) callTRFunc(f, v reflect.Value, step Transform) reflect.Value {
|
|
- v = sanitizeValue(v, f.Type().In(0))
|
|
|
|
if !s.dynChecker.Next() {
|
|
if !s.dynChecker.Next() {
|
|
return f.Call([]reflect.Value{v})[0]
|
|
return f.Call([]reflect.Value{v})[0]
|
|
}
|
|
}
|
|
@@ -343,8 +341,6 @@ func (s *state) callTRFunc(f, v reflect.Value, step Transform) reflect.Value {
|
|
}
|
|
}
|
|
|
|
|
|
func (s *state) callTTBFunc(f, x, y reflect.Value) bool {
|
|
func (s *state) callTTBFunc(f, x, y reflect.Value) bool {
|
|
- x = sanitizeValue(x, f.Type().In(0))
|
|
|
|
- y = sanitizeValue(y, f.Type().In(1))
|
|
|
|
if !s.dynChecker.Next() {
|
|
if !s.dynChecker.Next() {
|
|
return f.Call([]reflect.Value{x, y})[0].Bool()
|
|
return f.Call([]reflect.Value{x, y})[0].Bool()
|
|
}
|
|
}
|
|
@@ -372,19 +368,6 @@ func detectRaces(c chan<- reflect.Value, f reflect.Value, vs ...reflect.Value) {
|
|
ret = f.Call(vs)[0]
|
|
ret = f.Call(vs)[0]
|
|
}
|
|
}
|
|
|
|
|
|
-// sanitizeValue converts nil interfaces of type T to those of type R,
|
|
|
|
-// assuming that T is assignable to R.
|
|
|
|
-// Otherwise, it returns the input value as is.
|
|
|
|
-func sanitizeValue(v reflect.Value, t reflect.Type) reflect.Value {
|
|
|
|
- // TODO(≥go1.10): Workaround for reflect bug (https://golang.org/issue/22143).
|
|
|
|
- if !flags.AtLeastGo110 {
|
|
|
|
- if v.Kind() == reflect.Interface && v.IsNil() && v.Type() != t {
|
|
|
|
- return reflect.New(t).Elem()
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return v
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func (s *state) compareStruct(t reflect.Type, vx, vy reflect.Value) {
|
|
func (s *state) compareStruct(t reflect.Type, vx, vy reflect.Value) {
|
|
var addr bool
|
|
var addr bool
|
|
var vax, vay reflect.Value // Addressable versions of vx and vy
|
|
var vax, vay reflect.Value // Addressable versions of vx and vy
|