diff options
Diffstat (limited to 'src/cmd/compile/internal/gc/reflect.go')
-rw-r--r-- | src/cmd/compile/internal/gc/reflect.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/gc/reflect.go b/src/cmd/compile/internal/gc/reflect.go index 61ac67c0bc..0341ccabfa 100644 --- a/src/cmd/compile/internal/gc/reflect.go +++ b/src/cmd/compile/internal/gc/reflect.go @@ -1312,9 +1312,25 @@ ok: // ../../../../runtime/type.go:/structType // for security, only the exported fields. case TSTRUCT: + + // omitFieldForAwfulBoringCryptoKludge reports whether + // the field t should be omitted from the reflect data. + // In the crypto/... packages we omit an unexported field + // named "boring", to keep from breaking client code that + // expects rsa.PublicKey etc to have only public fields. + // As the name suggests, this is an awful kludge, but it is + // limited to the dev.boringcrypto branch and avoids + // much more invasive effects elsewhere. + omitFieldForAwfulBoringCryptoKludge := func(t *types.Field) bool { + return strings.HasPrefix(myimportpath, "crypto/") && t.Sym != nil && t.Sym.Name == "boring" + } + n := 0 for _, t1 := range t.Fields().Slice() { + if omitFieldForAwfulBoringCryptoKludge(t1) { + continue + } dtypesym(t1.Type) n++ } @@ -1342,6 +1358,9 @@ ok: ot = dextratype(s, ot, t, dataAdd) for _, f := range t.Fields().Slice() { + if omitFieldForAwfulBoringCryptoKludge(f) { + continue + } // ../../../../runtime/type.go:/structField ot = dnameField(s, ot, pkg, f) ot = dsymptr(s, ot, dtypesym(f.Type), 0) |