summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2013-01-22 14:29:38 -0800
committerBrad Fitzpatrick <bradfitz@golang.org>2013-01-22 14:29:38 -0800
commit93d92d51ddccbbc689f4b9adeded4f310ba0c363 (patch)
tree867510c12ec5a34bb85c6a2a8971a0d4bc234ea8 /src
parentb9f0a6bf6833f2f70caf6451133919a2807d0943 (diff)
downloadgo-git-93d92d51ddccbbc689f4b9adeded4f310ba0c363.tar.gz
cmd/api: fix type scrubbing
It wasn't removing names from func parameters for func types, and it was handling "a, b string" as "string", not "string, string". Fixes #4688 R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7181051
Diffstat (limited to 'src')
-rw-r--r--src/cmd/api/goapi.go10
-rw-r--r--src/cmd/api/testdata/src/pkg/p1/golden.txt8
-rw-r--r--src/cmd/api/testdata/src/pkg/p1/p1.go4
3 files changed, 17 insertions, 5 deletions
diff --git a/src/cmd/api/goapi.go b/src/cmd/api/goapi.go
index 6d39a463f6..1ee852ea79 100644
--- a/src/cmd/api/goapi.go
+++ b/src/cmd/api/goapi.go
@@ -879,7 +879,7 @@ func (w *Walker) walkTypeSpec(ts *ast.TypeSpec) {
case *ast.InterfaceType:
w.walkInterfaceType(name, t)
default:
- w.emitFeature(fmt.Sprintf("type %s %s", name, w.nodeString(ts.Type)))
+ w.emitFeature(fmt.Sprintf("type %s %s", name, w.nodeString(w.namelessType(ts.Type))))
}
}
@@ -1120,7 +1120,13 @@ func (w *Walker) namelessFieldList(fl *ast.FieldList) *ast.FieldList {
fl2 := &ast.FieldList{}
if fl != nil {
for _, f := range fl.List {
- fl2.List = append(fl2.List, w.namelessField(f))
+ repeats := 1
+ if len(f.Names) > 1 {
+ repeats = len(f.Names)
+ }
+ for i := 0; i < repeats; i++ {
+ fl2.List = append(fl2.List, w.namelessField(f))
+ }
}
}
return fl2
diff --git a/src/cmd/api/testdata/src/pkg/p1/golden.txt b/src/cmd/api/testdata/src/pkg/p1/golden.txt
index 180c8db434..9cbdefb77a 100644
--- a/src/cmd/api/testdata/src/pkg/p1/golden.txt
+++ b/src/cmd/api/testdata/src/pkg/p1/golden.txt
@@ -10,6 +10,7 @@ pkg p1, func Bar(int8, int16, int64)
pkg p1, func Bar1(int8, int16, int64) uint64
pkg p1, func Bar2(int8, int16, int64) (uint8, uint64)
pkg p1, func BarE() Error
+pkg p1, func PlainFunc(int, int, string) (*B, error)
pkg p1, func TakesFunc(func(int) int)
pkg p1, method (*B) JustOnB()
pkg p1, method (*B) OnBothTandBPtr()
@@ -37,20 +38,21 @@ pkg p1, type Embedded struct
pkg p1, type Error interface { Error, Temporary }
pkg p1, type Error interface, Error() string
pkg p1, type Error interface, Temporary() bool
-pkg p1, type I interface, unexported methods
+pkg p1, type FuncType func(int, int, string) (*B, error)
pkg p1, type I interface, Get(string) int64
pkg p1, type I interface, GetNamed(string) int64
pkg p1, type I interface, Name() string
pkg p1, type I interface, PackageTwoMeth()
pkg p1, type I interface, Set(string, int64)
+pkg p1, type I interface, unexported methods
pkg p1, type MyInt int
pkg p1, type Namer interface { Name }
pkg p1, type Namer interface, Name() string
+pkg p1, type Private interface, X()
+pkg p1, type Private interface, unexported methods
pkg p1, type Public interface { X, Y }
pkg p1, type Public interface, X()
pkg p1, type Public interface, Y()
-pkg p1, type Private interface, unexported methods
-pkg p1, type Private interface, X()
pkg p1, type S struct
pkg p1, type S struct, Public *int
pkg p1, type S struct, PublicTime time.Time
diff --git a/src/cmd/api/testdata/src/pkg/p1/p1.go b/src/cmd/api/testdata/src/pkg/p1/p1.go
index a18a6418fa..1af59d5ca9 100644
--- a/src/cmd/api/testdata/src/pkg/p1/p1.go
+++ b/src/cmd/api/testdata/src/pkg/p1/p1.go
@@ -149,8 +149,12 @@ type TPtrExported struct {
*Embedded
}
+type FuncType func(x, y int, s string) (b *B, err error)
+
type Embedded struct{}
+func PlainFunc(x, y int, s string) (b *B, err error)
+
func (*Embedded) OnEmbedded() {}
func (*T) JustOnT() {}