Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 3a35fb6

Browse files
authoredMar 16, 2020
Revert "Fix #71 Do + DoAndReturn signature change error msg (#395)" (#413)
This reverts commit f9b4ad1.
1 parent 064e67a commit 3a35fb6

File tree

4 files changed

+3
-1109
lines changed

4 files changed

+3
-1109
lines changed
 

‎gomock/call.go

+2-32
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import (
1919
"reflect"
2020
"strconv"
2121
"strings"
22-
23-
"github.com/golang/mock/gomock/internal/validate"
2422
)
2523

2624
// Call represents an expected call to a mock.
@@ -107,24 +105,10 @@ func (c *Call) MaxTimes(n int) *Call {
107105
// DoAndReturn declares the action to run when the call is matched.
108106
// The return values from this function are returned by the mocked function.
109107
// It takes an interface{} argument to support n-arity functions.
110-
// If the method signature of f is not compatible with the mocked function a
111-
// panic will be triggered. Both the arguments and return values of f are
112-
// validated.
113108
func (c *Call) DoAndReturn(f interface{}) *Call {
109+
// TODO: Check arity and types here, rather than dying badly elsewhere.
114110
v := reflect.ValueOf(f)
115111

116-
switch v.Kind() {
117-
case reflect.Func:
118-
mt := c.methodType
119-
120-
ft := v.Type()
121-
if err := validate.InputAndOutputSig(ft, mt); err != nil {
122-
panic(fmt.Sprintf("DoAndReturn: %s", err))
123-
}
124-
default:
125-
panic("DoAndReturn: argument must be a function")
126-
}
127-
128112
c.addAction(func(args []interface{}) []interface{} {
129113
vargs := make([]reflect.Value, len(args))
130114
ft := v.Type()
@@ -150,24 +134,10 @@ func (c *Call) DoAndReturn(f interface{}) *Call {
150134
// return values are ignored to retain backward compatibility. To use the
151135
// return values call DoAndReturn.
152136
// It takes an interface{} argument to support n-arity functions.
153-
// If the method signature of f is not compatible with the mocked function a
154-
// panic will be triggered. Only the arguments of f are validated; not the return
155-
// values.
156137
func (c *Call) Do(f interface{}) *Call {
138+
// TODO: Check arity and types here, rather than dying badly elsewhere.
157139
v := reflect.ValueOf(f)
158140

159-
switch v.Kind() {
160-
case reflect.Func:
161-
mt := c.methodType
162-
163-
ft := v.Type()
164-
if err := validate.InputSig(ft, mt); err != nil {
165-
panic(fmt.Sprintf("Do: %s", err))
166-
}
167-
default:
168-
panic("Do: argument must be a function")
169-
}
170-
171141
c.addAction(func(args []interface{}) []interface{} {
172142
vargs := make([]reflect.Value, len(args))
173143
ft := v.Type()

0 commit comments

Comments
 (0)
This repository has been archived.