Fix can't call callbacks for embedded pointers

This commit is contained in:
Jinzhu 2015-08-10 12:40:56 +08:00
parent 8efbe276e8
commit 1a07673e97
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 {
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 {
call(scope.Value)
if scope.IndirectValue().CanAddr() {
call(scope.IndirectValue().Addr().Interface())
} else {
call(scope.IndirectValue().Interface())
}
}
}