@@ -19,8 +19,6 @@ import (
19
19
"reflect"
20
20
"strconv"
21
21
"strings"
22
-
23
- "github.com/golang/mock/gomock/internal/validate"
24
22
)
25
23
26
24
// Call represents an expected call to a mock.
@@ -107,24 +105,10 @@ func (c *Call) MaxTimes(n int) *Call {
107
105
// DoAndReturn declares the action to run when the call is matched.
108
106
// The return values from this function are returned by the mocked function.
109
107
// 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.
113
108
func (c * Call ) DoAndReturn (f interface {}) * Call {
109
+ // TODO: Check arity and types here, rather than dying badly elsewhere.
114
110
v := reflect .ValueOf (f )
115
111
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
-
128
112
c .addAction (func (args []interface {}) []interface {} {
129
113
vargs := make ([]reflect.Value , len (args ))
130
114
ft := v .Type ()
@@ -150,24 +134,10 @@ func (c *Call) DoAndReturn(f interface{}) *Call {
150
134
// return values are ignored to retain backward compatibility. To use the
151
135
// return values call DoAndReturn.
152
136
// 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.
156
137
func (c * Call ) Do (f interface {}) * Call {
138
+ // TODO: Check arity and types here, rather than dying badly elsewhere.
157
139
v := reflect .ValueOf (f )
158
140
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
-
171
141
c .addAction (func (args []interface {}) []interface {} {
172
142
vargs := make ([]reflect.Value , len (args ))
173
143
ft := v .Type ()
0 commit comments