diff --git a/reflect.go b/reflect.go index f154474a..af5ed0fe 100644 --- a/reflect.go +++ b/reflect.go @@ -300,7 +300,7 @@ func (ri *reflectInspector) recordArgReflected(val ssa.Value, visited map[ssa.Va case *ssa.ChangeType: ri.recursivelyRecordUsedForReflect(val.X.Type()) - case *ssa.Const: + case *ssa.MakeSlice, *ssa.MakeMap, *ssa.MakeChan, *ssa.Const: ri.recursivelyRecordUsedForReflect(val.Type()) case *ssa.Global: ri.recursivelyRecordUsedForReflect(val.Type()) diff --git a/testdata/script/reflect.txtar b/testdata/script/reflect.txtar index c6469752..02789579 100644 --- a/testdata/script/reflect.txtar +++ b/testdata/script/reflect.txtar @@ -24,6 +24,7 @@ import ( "crypto/rand" "crypto/x509" "crypto/x509/pkix" + "encoding/gob" "encoding/json" "fmt" "math/big" @@ -410,6 +411,58 @@ type UnnamedStructFields struct { } } +func gobStruct() { + type gobAlias struct { + Security []map[string]struct { + List []string + Pad bool + } + } + alias := gobAlias{} + + gob.NewEncoder(os.Stdout).Encode(alias) + + alias.Security = make([]map[string]struct { + List []string + Pad bool + }, 0, len([]string{})) +} + +func gobMap() { + type gobAlias struct { + Security map[string]struct { + List []string + Pad bool + } + } + alias := gobAlias{} + + gob.NewEncoder(os.Stdout).Encode(alias) + + alias.Security = make(map[string]struct { + List []string + Pad bool + }, len([]string{})) +} + +func gobChan() { + type gobAlias struct { + Security chan struct { + List []string + Pad bool + } + } + + alias := gobAlias{} + + gob.NewEncoder(os.Stdout).Encode(alias) + + alias.Security = make(chan struct { + List []string + Pad bool + }, len([]string{})) +} + -- importedpkg/imported.go -- package importedpkg