Commit 9657e0b0 authored by Russ Cox's avatar Russ Cox

[dev.typealias] cmd/doc: update for type alias

For #18130.

Change-Id: I06b05a2b45a2aa6764053fc51e05883063572dad
Reviewed-on: https://go-review.googlesource.com/35670
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
parent de2e5459
......@@ -71,6 +71,7 @@ var tests = []test{
`const MultiLineConst = ...`, // Multi line constant.
`var MultiLineVar = map\[struct{ ... }\]struct{ ... }{ ... }`, // Multi line variable.
`func MultiLineFunc\(x interface{ ... }\) \(r struct{ ... }\)`, // Multi line function.
`type T1 = T2`, // Type alias
},
[]string{
`const internalConstant = 2`, // No internal constants.
......@@ -89,6 +90,7 @@ var tests = []test{
`unexportedTypedConstant`, // No unexported typed constant.
`Field`, // No fields.
`Method`, // No methods.
`type T1 T2`, // Type alias does not display as type declaration.
},
},
// Package dump -u
......@@ -265,6 +267,18 @@ var tests = []test{
`error`, // No embedded error.
},
},
// Type T1 dump (alias).
{
"type T1",
[]string{p+".T1"},
[]string{
`type T1 = T2`,
},
[]string{
`type T1 T2`,
`type ExportedType`,
},
},
// Type -u with unexported fields.
{
"type with unexported fields and -u",
......
......@@ -258,7 +258,11 @@ func (pkg *Package) oneLineNodeDepth(node ast.Node, depth int) string {
return fmt.Sprintf("func %s%s%s", recv, name, fnc)
case *ast.TypeSpec:
return fmt.Sprintf("type %s %s", n.Name.Name, pkg.oneLineNodeDepth(n.Type, depth))
sep := " "
if n.Assign.IsValid() {
sep = " = "
}
return fmt.Sprintf("type %s%s%s", n.Name.Name, sep, pkg.oneLineNodeDepth(n.Type, depth))
case *ast.FuncType:
var params []string
......
......@@ -172,3 +172,7 @@ const (
)
const ConstGroup4 ExportedType = ExportedType{}
type T2 int
type T1 = T2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment