1
0
mirror of https://github.com/golang/go synced 2024-11-26 08:38:01 -07:00

go/types: remove unused gcCompatibilityMode flag (cleanup)

This is a port of CL 339831 to go/types.

gcCompatibilityMode is unused, and x/tools/go/types no longer exists, so
delete it.

Change-Id: I886d8c24b7aa6511934ac78549f07a88a18e950b
Reviewed-on: https://go-review.googlesource.com/c/go/+/342429
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Robert Findley 2021-08-15 20:32:29 -04:00
parent c88e3ff648
commit 0b61dc4577

View File

@ -40,27 +40,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. // TypeString returns the string representation of typ.
// The Qualifier controls the printing of // The Qualifier controls the printing of
// package-level objects, and may be nil. // package-level objects, and may be nil.
@ -108,15 +87,6 @@ func writeType(buf *bytes.Buffer, typ Type, qf Qualifier, visited []Type) {
} }
} }
if gcCompatibilityMode {
// forget the alias names
switch t.kind {
case Byte:
t = Typ[Uint8]
case Rune:
t = Typ[Int32]
}
}
buf.WriteString(t.name) buf.WriteString(t.name)
case *Array: case *Array:
@ -175,47 +145,8 @@ func writeType(buf *bytes.Buffer, typ Type, qf Qualifier, visited []Type) {
} }
case *Interface: 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{") buf.WriteString("interface{")
empty := true 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() {
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 // print explicit interface methods and embedded types
for i, m := range t.methods { for i, m := range t.methods {
if i > 0 { if i > 0 {
@ -235,7 +166,6 @@ func writeType(buf *bytes.Buffer, typ Type, qf Qualifier, visited []Type) {
writeType(buf, typ, qf, visited) writeType(buf, typ, qf, visited)
empty = false empty = false
} }
}
// print /* incomplete */ if needed to satisfy existing tests // print /* incomplete */ if needed to satisfy existing tests
// TODO(gri) get rid of this eventually // TODO(gri) get rid of this eventually
if debug && t.tset == nil { if debug && t.tset == nil {