diff options
author | Robert Griesemer <gri@golang.org> | 2010-02-24 13:24:37 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2010-02-24 13:24:37 -0800 |
commit | 25df35f2c7eda611664834fa15d158482d800de4 (patch) | |
tree | e81ca00f610f3f60e00d1914af60ee6f1c5ad714 /src/pkg/go | |
parent | 06b944d91954aaef6043546899972ad81feca159 (diff) | |
download | golang-25df35f2c7eda611664834fa15d158482d800de4.tar.gz |
gofmt: don't print ()'s around function-typed results (not needed anymore)
- add extra test cases to go/printer tests
- apply gofmt to src and misc
R=rsc
CC=golang-dev
http://codereview.appspot.com/223041
Diffstat (limited to 'src/pkg/go')
-rw-r--r-- | src/pkg/go/printer/nodes.go | 12 | ||||
-rw-r--r-- | src/pkg/go/printer/testdata/declarations.golden | 7 | ||||
-rw-r--r-- | src/pkg/go/printer/testdata/declarations.input | 7 |
3 files changed, 17 insertions, 9 deletions
diff --git a/src/pkg/go/printer/nodes.go b/src/pkg/go/printer/nodes.go index dd6b1db6b..6096751bd 100644 --- a/src/pkg/go/printer/nodes.go +++ b/src/pkg/go/printer/nodes.go @@ -241,19 +241,13 @@ func (p *printer) signature(params, result []*ast.Field, multiLine *bool) { p.parameters(params, multiLine) if result != nil { p.print(blank) - if len(result) == 1 && result[0].Names == nil { - // single anonymous result; no ()'s unless it's a function type - f := result[0] - if _, isFtyp := f.Type.(*ast.FuncType); !isFtyp { - p.expr(f.Type, multiLine) - return - } + // single anonymous result; no ()'s + p.expr(result[0].Type, multiLine) + return } - p.parameters(result, multiLine) } - return } diff --git a/src/pkg/go/printer/testdata/declarations.golden b/src/pkg/go/printer/testdata/declarations.golden index 9998103cf..b15e52ad6 100644 --- a/src/pkg/go/printer/testdata/declarations.golden +++ b/src/pkg/go/printer/testdata/declarations.golden @@ -471,6 +471,13 @@ func _() { } +// formatting of function results +func _() func() {} +func _() func(int) { return nil } +func _() func(int) int { return nil } +func _() func(int) func(int) func() { return nil } + + // formatting of consecutive single-line functions func _() {} func _() {} diff --git a/src/pkg/go/printer/testdata/declarations.input b/src/pkg/go/printer/testdata/declarations.input index fd80cb626..1d1dc45f0 100644 --- a/src/pkg/go/printer/testdata/declarations.input +++ b/src/pkg/go/printer/testdata/declarations.input @@ -468,6 +468,13 @@ func _() { } +// formatting of function results +func _() func() {} +func _() func(int) { return nil } +func _() func(int) int { return nil } +func _() func(int) func(int) func() { return nil } + + // formatting of consecutive single-line functions func _() {} func _() {} |