Skip to content

Commit

Permalink
fix: handling of nil passed as an arg to a typed interface parameter …
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunco committed Nov 20, 2021
1 parent 9201d3f commit 94d0bd5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ func (h *reflectFunc) fnArgs(msg *Message) ([]reflect.Value, error) {
inType := h.ft.In(inStart + i)

if inType.Kind() == reflect.Interface {
if !v.Type().Implements(inType) {
// If the input value is an untyped nil, simply create a new
// typed nil so that the subsequent .Call() works
if !v.IsValid() {
v = reflect.Zero(inType)
} else if !v.Type().Implements(inType) {
hasWrongType = true
break
}
Expand Down

0 comments on commit 94d0bd5

Please sign in to comment.