Commit 17a48e0a authored by Chris Broadfoot's avatar Chris Broadfoot

all: merge master into release-branch.go1.7

Change-Id: I77d1665af543dc71f30b2afa48eac411de11afc7
parents c628d83e 50edddb7
go1.7rc4
\ No newline at end of file
...@@ -61,6 +61,7 @@ var tests = []test{ ...@@ -61,6 +61,7 @@ var tests = []test{
`var ExportedVariable = 1`, // Simple variable. `var ExportedVariable = 1`, // Simple variable.
`var VarOne = 1`, // First entry in variable block. `var VarOne = 1`, // First entry in variable block.
`func ExportedFunc\(a int\) bool`, // Function. `func ExportedFunc\(a int\) bool`, // Function.
`func ReturnUnexported\(\) unexportedType`, // Function with unexported return type.
`type ExportedType struct { ... }`, // Exported type. `type ExportedType struct { ... }`, // Exported type.
`const ExportedTypedConstant ExportedType = iota`, // Typed constant. `const ExportedTypedConstant ExportedType = iota`, // Typed constant.
`const ExportedTypedConstant_unexported unexportedType`, // Typed constant, exported for unexported type. `const ExportedTypedConstant_unexported unexportedType`, // Typed constant, exported for unexported type.
...@@ -92,6 +93,7 @@ var tests = []test{ ...@@ -92,6 +93,7 @@ var tests = []test{
`const ExportedConstant = 1`, // Simple constant. `const ExportedConstant = 1`, // Simple constant.
`const internalConstant = 2`, // Internal constants. `const internalConstant = 2`, // Internal constants.
`func internalFunc\(a int\) bool`, // Internal functions. `func internalFunc\(a int\) bool`, // Internal functions.
`func ReturnUnexported\(\) unexportedType`, // Function with unexported return type.
}, },
[]string{ []string{
`Comment about exported constant`, // No comment for simple constant. `Comment about exported constant`, // No comment for simple constant.
...@@ -221,6 +223,7 @@ var tests = []test{ ...@@ -221,6 +223,7 @@ var tests = []test{
`func \(ExportedType\) ExportedMethod\(a int\) bool`, `func \(ExportedType\) ExportedMethod\(a int\) bool`,
`const ExportedTypedConstant ExportedType = iota`, // Must include associated constant. `const ExportedTypedConstant ExportedType = iota`, // Must include associated constant.
`func ExportedTypeConstructor\(\) \*ExportedType`, // Must include constructor. `func ExportedTypeConstructor\(\) \*ExportedType`, // Must include constructor.
`io.Reader.*Comment on line with embedded Reader.`,
}, },
[]string{ []string{
`unexportedField`, // No unexported field. `unexportedField`, // No unexported field.
...@@ -228,6 +231,7 @@ var tests = []test{ ...@@ -228,6 +231,7 @@ var tests = []test{
`Comment about exported method.`, // No comment about exported method. `Comment about exported method.`, // No comment about exported method.
`unexportedMethod`, // No unexported method. `unexportedMethod`, // No unexported method.
`unexportedTypedConstant`, // No unexported constant. `unexportedTypedConstant`, // No unexported constant.
`error`, // No embedded error.
}, },
}, },
// Type -u with unexported fields. // Type -u with unexported fields.
...@@ -243,6 +247,8 @@ var tests = []test{ ...@@ -243,6 +247,8 @@ var tests = []test{
`\*ExportedEmbeddedType.*Comment on line with exported embedded \*field.`, `\*ExportedEmbeddedType.*Comment on line with exported embedded \*field.`,
`unexportedType.*Comment on line with unexported embedded field.`, `unexportedType.*Comment on line with unexported embedded field.`,
`\*unexportedType.*Comment on line with unexported embedded \*field.`, `\*unexportedType.*Comment on line with unexported embedded \*field.`,
`io.Reader.*Comment on line with embedded Reader.`,
`error.*Comment on line with embedded error.`,
`func \(ExportedType\) unexportedMethod\(a int\) bool`, `func \(ExportedType\) unexportedMethod\(a int\) bool`,
`unexportedTypedConstant`, `unexportedTypedConstant`,
}, },
...@@ -274,6 +280,8 @@ var tests = []test{ ...@@ -274,6 +280,8 @@ var tests = []test{
`type ExportedInterface interface`, // Interface definition. `type ExportedInterface interface`, // Interface definition.
`Comment before exported method.*\n.*ExportedMethod\(\)` + `Comment before exported method.*\n.*ExportedMethod\(\)` +
`.*Comment on line with exported method`, `.*Comment on line with exported method`,
`io.Reader.*Comment on line with embedded Reader.`,
`error.*Comment on line with embedded error.`,
`Has unexported methods`, `Has unexported methods`,
}, },
[]string{ []string{
...@@ -293,6 +301,8 @@ var tests = []test{ ...@@ -293,6 +301,8 @@ var tests = []test{
`Comment before exported method.*\n.*ExportedMethod\(\)` + `Comment before exported method.*\n.*ExportedMethod\(\)` +
`.*Comment on line with exported method`, `.*Comment on line with exported method`,
`unexportedMethod\(\).*Comment on line with unexported method.`, `unexportedMethod\(\).*Comment on line with unexported method.`,
`io.Reader.*Comment on line with embedded Reader.`,
`error.*Comment on line with embedded error.`,
}, },
[]string{ []string{
`Has unexported methods`, `Has unexported methods`,
......
...@@ -317,10 +317,12 @@ func (pkg *Package) funcSummary(funcs []*doc.Func, showConstructors bool) { ...@@ -317,10 +317,12 @@ func (pkg *Package) funcSummary(funcs []*doc.Func, showConstructors bool) {
isConstructor = make(map[*doc.Func]bool) isConstructor = make(map[*doc.Func]bool)
for _, typ := range pkg.doc.Types { for _, typ := range pkg.doc.Types {
for _, constructor := range typ.Funcs { for _, constructor := range typ.Funcs {
if isExported(typ.Name) {
isConstructor[constructor] = true isConstructor[constructor] = true
} }
} }
} }
}
for _, fun := range funcs { for _, fun := range funcs {
decl := fun.Decl decl := fun.Decl
// Exported functions only. The go/doc package does not include methods here. // Exported functions only. The go/doc package does not include methods here.
...@@ -494,14 +496,19 @@ func trimUnexportedElems(spec *ast.TypeSpec) { ...@@ -494,14 +496,19 @@ func trimUnexportedElems(spec *ast.TypeSpec) {
} }
switch typ := spec.Type.(type) { switch typ := spec.Type.(type) {
case *ast.StructType: case *ast.StructType:
typ.Fields = trimUnexportedFields(typ.Fields, "fields") typ.Fields = trimUnexportedFields(typ.Fields, false)
case *ast.InterfaceType: case *ast.InterfaceType:
typ.Methods = trimUnexportedFields(typ.Methods, "methods") typ.Methods = trimUnexportedFields(typ.Methods, true)
} }
} }
// trimUnexportedFields returns the field list trimmed of unexported fields. // trimUnexportedFields returns the field list trimmed of unexported fields.
func trimUnexportedFields(fields *ast.FieldList, what string) *ast.FieldList { func trimUnexportedFields(fields *ast.FieldList, isInterface bool) *ast.FieldList {
what := "methods"
if !isInterface {
what = "fields"
}
trimmed := false trimmed := false
list := make([]*ast.Field, 0, len(fields.List)) list := make([]*ast.Field, 0, len(fields.List))
for _, field := range fields.List { for _, field := range fields.List {
...@@ -511,12 +518,23 @@ func trimUnexportedFields(fields *ast.FieldList, what string) *ast.FieldList { ...@@ -511,12 +518,23 @@ func trimUnexportedFields(fields *ast.FieldList, what string) *ast.FieldList {
// Nothing else is allowed. // Nothing else is allowed.
switch ident := field.Type.(type) { switch ident := field.Type.(type) {
case *ast.Ident: case *ast.Ident:
if isInterface && ident.Name == "error" && ident.Obj == nil {
// For documentation purposes, we consider the builtin error
// type special when embedded in an interface, such that it
// always gets shown publicly.
list = append(list, field)
continue
}
names = []*ast.Ident{ident} names = []*ast.Ident{ident}
case *ast.StarExpr: case *ast.StarExpr:
// Must have the form *identifier. // Must have the form *identifier.
if ident, ok := ident.X.(*ast.Ident); ok { // This is only valid on embedded types in structs.
if ident, ok := ident.X.(*ast.Ident); ok && !isInterface {
names = []*ast.Ident{ident} names = []*ast.Ident{ident}
} }
case *ast.SelectorExpr:
// An embedded type may refer to a type in another package.
names = []*ast.Ident{ident.Sel}
} }
if names == nil { if names == nil {
// Can only happen if AST is incorrect. Safe to continue with a nil list. // Can only happen if AST is incorrect. Safe to continue with a nil list.
......
...@@ -66,6 +66,8 @@ type ExportedType struct { ...@@ -66,6 +66,8 @@ type ExportedType struct {
*ExportedEmbeddedType // Comment on line with exported embedded *field. *ExportedEmbeddedType // Comment on line with exported embedded *field.
unexportedType // Comment on line with unexported embedded field. unexportedType // Comment on line with unexported embedded field.
*unexportedType // Comment on line with unexported embedded *field. *unexportedType // Comment on line with unexported embedded *field.
io.Reader // Comment on line with embedded Reader.
error // Comment on line with embedded error.
} }
// Comment about exported method. // Comment about exported method.
...@@ -96,6 +98,8 @@ type ExportedInterface interface { ...@@ -96,6 +98,8 @@ type ExportedInterface interface {
// Comment before exported method. // Comment before exported method.
ExportedMethod() // Comment on line with exported method. ExportedMethod() // Comment on line with exported method.
unexportedMethod() // Comment on line with unexported method. unexportedMethod() // Comment on line with unexported method.
io.Reader // Comment on line with embedded Reader.
error // Comment on line with embedded error.
} }
// Comment about unexported type. // Comment about unexported type.
...@@ -119,3 +123,6 @@ const unexportedTypedConstant unexportedType = 1 // In a separate section to tes ...@@ -119,3 +123,6 @@ const unexportedTypedConstant unexportedType = 1 // In a separate section to tes
// For case matching. // For case matching.
const CaseMatch = 1 const CaseMatch = 1
const Casematch = 2 const Casematch = 2
func ReturnUnexported() unexportedType { return 0 }
func ReturnExported() ExportedType { return ExportedType{} }
...@@ -196,15 +196,16 @@ timeloop: ...@@ -196,15 +196,16 @@ timeloop:
systime: systime:
// Fall back to system call (usually first call in this thread) // Fall back to system call (usually first call in this thread)
LEAL 12(SP), AX // must be non-nil, unused LEAL 16(SP), AX // must be non-nil, unused
MOVL AX, 4(SP) MOVL AX, 4(SP)
MOVL $0, 8(SP) // time zone pointer MOVL $0, 8(SP) // time zone pointer
MOVL $0, 12(SP) // required as of Sierra; Issue 16570
MOVL $116, AX MOVL $116, AX
INT $0x80 INT $0x80
CMPL AX, $0 CMPL AX, $0
JNE inreg JNE inreg
MOVL 12(SP), AX MOVL 16(SP), AX
MOVL 16(SP), DX MOVL 20(SP), DX
inreg: inreg:
// sec is in AX, usec in DX // sec is in AX, usec in DX
// convert to DX:AX nsec // convert to DX:AX nsec
......
...@@ -157,6 +157,7 @@ systime: ...@@ -157,6 +157,7 @@ systime:
// Fall back to system call (usually first call in this thread). // Fall back to system call (usually first call in this thread).
MOVQ SP, DI MOVQ SP, DI
MOVQ $0, SI MOVQ $0, SI
MOVQ $0, DX // required as of Sierra; Issue 16570
MOVL $(0x2000000+116), AX MOVL $(0x2000000+116), AX
SYSCALL SYSCALL
CMPQ AX, $0 CMPQ AX, $0
......
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