diff options
author | Robert Griesemer <gri@golang.org> | 2021-08-04 12:12:27 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-08-05 19:36:52 +0000 |
commit | f14908d01b8c4832f9ad3939165d5eec969635e1 (patch) | |
tree | 7b4162163e4bc871705c001560ceba2b8aaf784c /src | |
parent | bb5608dd5d056519bd90666b815e0b2bf65e5ee8 (diff) | |
download | go-git-f14908d01b8c4832f9ad3939165d5eec969635e1.tar.gz |
[dev.typeparams] cmd/compile/internal/types2: remove unused gcCompatibilityMode flag (cleanup)
This flag is not needed by types2 (and possibly can also be removed
from go/types). Removed some unnecessary comments along the way.
Updates #46174.
Change-Id: I1a7a99f724205a084d1c9850bce6f6f5d33f83ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/339831
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/compile/internal/types2/typestring.go | 98 |
1 files changed, 13 insertions, 85 deletions
diff --git a/src/cmd/compile/internal/types2/typestring.go b/src/cmd/compile/internal/types2/typestring.go index 558da50528..1416008b16 100644 --- a/src/cmd/compile/internal/types2/typestring.go +++ b/src/cmd/compile/internal/types2/typestring.go @@ -39,27 +39,6 @@ func RelativeTo(pkg *Package) Qualifier { } } -// If gcCompatibilityMode is set, printing of types is modified -// to match the representation of some types in the gc compiler: -// -// - byte and rune lose their alias name and simply stand for -// uint8 and int32 respectively -// - embedded interfaces get flattened (the embedding info is lost, -// and certain recursive interface types cannot be printed anymore) -// -// This makes it easier to compare packages computed with the type- -// checker vs packages imported from gc export data. -// -// Caution: This flag affects all uses of WriteType, globally. -// It is only provided for testing in conjunction with -// gc-generated data. -// -// This flag is exported in the x/tools/go/types package. We don't -// need it at the moment in the std repo and so we don't export it -// anymore. We should eventually try to remove it altogether. -// TODO(gri) remove this -var gcCompatibilityMode bool - // TypeString returns the string representation of typ. // The Qualifier controls the printing of // package-level objects, and may be nil. @@ -106,16 +85,6 @@ func writeType(buf *bytes.Buffer, typ Type, qf Qualifier, visited []Type) { break } } - - if gcCompatibilityMode { - // forget the alias names - switch t.kind { - case Byte: - t = Typ[Uint8] - case Rune: - t = Typ[Int32] - } - } buf.WriteString(t.name) case *Array: @@ -174,66 +143,25 @@ func writeType(buf *bytes.Buffer, typ Type, qf Qualifier, visited []Type) { } case *Interface: - // We write the source-level methods and embedded types rather - // than the actual method set since resolved method signatures - // may have non-printable cycles if parameters have embedded - // interface types that (directly or indirectly) embed the - // current interface. For instance, consider the result type - // of m: - // - // type T interface{ - // m() interface{ T } - // } - // buf.WriteString("interface{") empty := true - if gcCompatibilityMode { - // print flattened interface - // (useful to compare against gc-generated interfaces) - tset := t.typeSet() - for i, m := range tset.methods { - if i > 0 { - buf.WriteString("; ") - } - buf.WriteString(m.name) - writeSignature(buf, m.typ.(*Signature), qf, visited) - empty = false - } - if !empty && tset.hasTerms() { + for i, m := range t.methods { + if i > 0 { buf.WriteString("; ") } - first := true - tset.is(func(t *term) bool { - if !first { - buf.WriteByte('|') - } - first = false - if t.tilde { - buf.WriteByte('~') - } - writeType(buf, t.typ, qf, visited) - return true - }) - } else { - // print explicit interface methods and embedded types - for i, m := range t.methods { - if i > 0 { - buf.WriteString("; ") - } - buf.WriteString(m.name) - writeSignature(buf, m.typ.(*Signature), qf, visited) - empty = false - } - if !empty && len(t.embeddeds) > 0 { + buf.WriteString(m.name) + writeSignature(buf, m.typ.(*Signature), qf, visited) + empty = false + } + if !empty && len(t.embeddeds) > 0 { + buf.WriteString("; ") + } + for i, typ := range t.embeddeds { + if i > 0 { buf.WriteString("; ") } - for i, typ := range t.embeddeds { - if i > 0 { - buf.WriteString("; ") - } - writeType(buf, typ, qf, visited) - empty = false - } + writeType(buf, typ, qf, visited) + empty = false } // print /* incomplete */ if needed to satisfy existing tests // TODO(gri) get rid of this eventually |