diff --git a/common/collections/append.go b/common/collections/append.go index e1008843b96..97bf8498896 100644 --- a/common/collections/append.go +++ b/common/collections/append.go @@ -59,7 +59,7 @@ func Append(to interface{}, from ...interface{}) (interface{}, error) { for _, f := range from { fv := reflect.ValueOf(f) - if tot != fv.Type() { + if !fv.Type().AssignableTo(tot) { return nil, fmt.Errorf("append element type mismatch: expected %v, got %v", tot, fv.Type()) } tov = reflect.Append(tov, fv) diff --git a/common/collections/append_test.go b/common/collections/append_test.go index e3361fb26be..f89ec60f0b7 100644 --- a/common/collections/append_test.go +++ b/common/collections/append_test.go @@ -43,7 +43,13 @@ func TestAppend(t *testing.T) { tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}, &tstSlicer{"c"}}}, + {testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}}, + []interface{}{&tstSlicerIn1{"c"}}, + testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}, &tstSlicerIn1{"c"}}}, // Errors + {testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}}, + []interface{}{"c"}, + false}, {"", []interface{}{[]string{"a", "b"}}, false}, // No string concatenation. {"ab",