[dev.typeparams] cmd/compile/internal/types2: print "incomplete" for interfaces in debug mode only

The /* incomplete */ comment printed for interfaces that have not been
"completed" yet is not useful for end-users; it's here for type-checker
debugging. Rather than trying to pass through a debug flag through all
print routines (which may require new exported API), simply don't print
the comment unless we have the debug flag set inside the type-checker.

For #46167.

Change-Id: Ibd22edfe63001dfd2b814eeb94c2d54d35afd88c
Reviewed-on: https://go-review.googlesource.com/c/go/+/320150
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Robert Griesemer 2021-05-14 10:05:16 -07:00
parent 03ed590e51
commit 0d1e293b23
3 changed files with 8 additions and 1 deletions

View file

@ -7,3 +7,6 @@ package types2
func init() {
acceptMethodTypeParams = true
}
// Debug is set if types2 is built with debug mode enabled.
const Debug = debug

View file

@ -226,7 +226,7 @@ func writeType(buf *bytes.Buffer, typ Type, qf Qualifier, visited []Type) {
empty = false
}
}
if t.allMethods == nil || len(t.methods) > len(t.allMethods) {
if debug && (t.allMethods == nil || len(t.methods) > len(t.allMethods)) {
if !empty {
buf.WriteByte(' ')
}

View file

@ -138,6 +138,10 @@ func TestTypeString(t *testing.T) {
var nopos syntax.Pos
func TestIncompleteInterfaces(t *testing.T) {
if !Debug {
t.Skip("requires type checker to be compiled with debug = true")
}
sig := NewSignature(nil, nil, nil, false)
m := NewFunc(nopos, nil, "m", sig)
for _, test := range []struct {