aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/doc/pkg.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2021-12-18 15:54:38 -0800
committerIan Lance Taylor <iant@golang.org>2021-12-20 23:32:14 +0000
commit6713b5dbbc4b3bbfa2022538501c7f8104f1e5fd (patch)
tree8687310c23dc1b55d8b72960ef0999c6d35ac4cf /src/cmd/doc/pkg.go
parent9901d9e87a47b775edd0e75edb19ba696091603e (diff)
downloadgo-6713b5dbbc4b3bbfa2022538501c7f8104f1e5fd.tar.xz
cmd/doc: don't log on constraint type elements
Fixes #50256 Change-Id: I2327a0b28f8173c801ed2946bec8083967667027 Reviewed-on: https://go-review.googlesource.com/c/go/+/373314 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/doc/pkg.go')
-rw-r--r--src/cmd/doc/pkg.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cmd/doc/pkg.go b/src/cmd/doc/pkg.go
index f51efe08af..0266600730 100644
--- a/src/cmd/doc/pkg.go
+++ b/src/cmd/doc/pkg.go
@@ -865,6 +865,7 @@ func trimUnexportedFields(fields *ast.FieldList, isInterface bool) *ast.FieldLis
if len(names) == 0 {
// Embedded type. Use the name of the type. It must be of the form ident or
// pkg.ident (for structs and interfaces), or *ident or *pkg.ident (structs only).
+ // Or a type embedded in a constraint.
// Nothing else is allowed.
ty := field.Type
if se, ok := field.Type.(*ast.StarExpr); !isInterface && ok {
@@ -872,6 +873,7 @@ func trimUnexportedFields(fields *ast.FieldList, isInterface bool) *ast.FieldLis
// embedded types in structs.
ty = se.X
}
+ constraint := false
switch ident := ty.(type) {
case *ast.Ident:
if isInterface && ident.Name == "error" && ident.Obj == nil {
@@ -885,8 +887,12 @@ func trimUnexportedFields(fields *ast.FieldList, isInterface bool) *ast.FieldLis
case *ast.SelectorExpr:
// An embedded type may refer to a type in another package.
names = []*ast.Ident{ident.Sel}
+ default:
+ // An approximation or union or type
+ // literal in an interface.
+ constraint = true
}
- if names == nil {
+ if names == nil && !constraint {
// Can only happen if AST is incorrect. Safe to continue with a nil list.
log.Print("invalid program: unexpected type for embedded field")
}