diff --git a/codec/gen.go b/codec/gen.go index 7c351b5e..8544f04f 100644 --- a/codec/gen.go +++ b/codec/gen.go @@ -164,6 +164,16 @@ type genRunner struct { // // Library users: *DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.* func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeInfos, typ ...reflect.Type) { + // trim out all types which already implement Selfer + typ2 := make([]reflect.Type, 0, len(typ)) + for _, t := range typ { + if reflect.PtrTo(t).Implements(selferTyp) || t.Implements(selferTyp) { + continue + } + typ2 = append(typ2, t) + } + typ = typ2 + if len(typ) == 0 { return }