mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[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:
parent
03ed590e51
commit
0d1e293b23
3 changed files with 8 additions and 1 deletions
|
|
@ -7,3 +7,6 @@ package types2
|
||||||
func init() {
|
func init() {
|
||||||
acceptMethodTypeParams = true
|
acceptMethodTypeParams = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Debug is set if types2 is built with debug mode enabled.
|
||||||
|
const Debug = debug
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,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(' ')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,10 @@ func TestTypeString(t *testing.T) {
|
||||||
var nopos syntax.Pos
|
var nopos syntax.Pos
|
||||||
|
|
||||||
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(nopos, nil, "m", sig)
|
m := NewFunc(nopos, nil, "m", sig)
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue