Allow more flexible callback return error type.

This commit is contained in:
Mitar
2021-12-13 00:02:56 +01:00
committed by Alec Thomas
parent deebf0b09b
commit ece1f6d8cb
2 changed files with 47 additions and 2 deletions
+2 -2
View File
@@ -79,8 +79,8 @@ func getMethod(value reflect.Value, name string) reflect.Value {
func callMethod(name string, v, f reflect.Value, bindings bindings) error {
in := []reflect.Value{}
t := f.Type()
if t.NumOut() != 1 || t.Out(0) != callbackReturnSignature {
return fmt.Errorf("return value of %T.%s() must be exactly \"error\"", v.Type(), name)
if t.NumOut() != 1 || !t.Out(0).Implements(callbackReturnSignature) {
return fmt.Errorf("return value of %T.%s() must implement \"error\"", v.Type(), name)
}
for i := 0; i < t.NumIn(); i++ {
pt := t.In(i)