1
0
mirror of https://github.com/golang/go synced 2024-11-17 12:44:49 -07:00

[dev.typeparams] go/types: print "incomplete" for interfaces in debug mode only

This is a straightforward port of CL 320150 to go/types.

Fixes #46167

Change-Id: Id1845046f598ac4fefd68cda6a5a03b7a5fc5a4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/324731
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:
Rob Findley 2021-06-03 09:49:21 -04:00 committed by Robert Findley
parent 655246f99a
commit cd6e9df446
3 changed files with 8 additions and 1 deletions

View File

@ -9,3 +9,6 @@ package types
func SetGoVersion(config *Config, goVersion string) { func SetGoVersion(config *Config, goVersion string) {
config.goVersion = goVersion config.goVersion = goVersion
} }
// Debug is set if go/types is built with debug mode enabled.
const Debug = debug

View File

@ -227,7 +227,7 @@ func writeType(buf *bytes.Buffer, typ Type, qf Qualifier, visited []Type) {
empty = false 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 { if !empty {
buf.WriteByte(' ') buf.WriteByte(' ')
} }

View File

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