Fix can't call callbacks for embedded pointers

This commit is contained in:
Jinzhu 2015-08-10 12:40:56 +08:00
parent ff3c23c9e9
commit 905b6232a3
1 changed files with 10 additions and 2 deletions

View File

@ -222,10 +222,18 @@ func (scope *Scope) CallMethod(name string, checkError bool) {
if values := scope.IndirectValue(); values.Kind() == reflect.Slice { if values := scope.IndirectValue(); values.Kind() == reflect.Slice {
for i := 0; i < values.Len(); i++ { for i := 0; i < values.Len(); i++ {
call(values.Index(i).Addr().Interface()) value := values.Index(i).Addr().Interface()
if values.Index(i).Kind() == reflect.Ptr {
value = values.Index(i).Interface()
}
call(value)
} }
} else { } else {
call(scope.Value) if scope.IndirectValue().CanAddr() {
call(scope.IndirectValue().Addr().Interface())
} else {
call(scope.IndirectValue().Interface())
}
} }
} }