Skip to content

Commit 2d98a4b

Browse files
committed
go/types: use a typeWriter to write types (cleanup)
This is a port of CL 345890 to go/types. Change-Id: I98162deaf044b2194b05dc51e6948e227216fc4d Reviewed-on: https://go-review.googlesource.com/c/go/+/346554 Trust: Robert Findley <[email protected]> Run-TryBot: Robert Findley <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent b2f09cd commit 2d98a4b

File tree

5 files changed

+121
-116
lines changed

5 files changed

+121
-116
lines changed

src/go/types/object.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ func writeObject(buf *bytes.Buffer, obj Object, qf Qualifier) {
430430
return
431431
}
432432
if named, _ := typ.(*Named); named != nil && named.TParams().Len() > 0 {
433-
writeTParamList(buf, named.TParams().list(), qf, nil)
433+
newTypeWriter(buf, qf).tParamList(named.TParams().list())
434434
}
435435
if tname.IsAlias() {
436436
buf.WriteString(" =")

src/go/types/subst.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,9 @@ func instantiatedHash(typ *Named, targs []Type) string {
262262
assert(instanceHashing == 0)
263263
instanceHashing++
264264
var buf bytes.Buffer
265-
writeTypeName(&buf, typ.obj, nil)
266-
buf.WriteByte('[')
267-
writeTypeList(&buf, targs, nil, nil)
268-
buf.WriteByte(']')
265+
w := newTypeWriter(&buf, nil)
266+
w.typeName(typ.obj)
267+
w.typeList(targs)
269268
instanceHashing--
270269

271270
// With respect to the represented type, whether a

src/go/types/typelists.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ func (l *TypeList) String() string {
5959
return "[]"
6060
}
6161
var buf bytes.Buffer
62-
buf.WriteByte('[')
63-
writeTypeList(&buf, l.types, nil, nil)
64-
buf.WriteByte(']')
62+
newTypeWriter(&buf, nil).typeList(l.types)
6563
return buf.String()
6664
}
6765

0 commit comments

Comments
 (0)