]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile/internal/types2: print "incomplete" for interfaces in...
authorRobert Griesemer <gri@golang.org>
Fri, 14 May 2021 17:05:16 +0000 (10:05 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 14 May 2021 22:42:22 +0000 (22:42 +0000)
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>
src/cmd/compile/internal/types2/types_test.go
src/cmd/compile/internal/types2/typestring.go
src/cmd/compile/internal/types2/typestring_test.go

index 11dca0b53de86421a3a34f5ae505d90dca61d3f2..1525844f2dfcc2cbf07784b75afe6cfb9bbdd9ab 100644 (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
index 40016697b7c90f99c6319f0dae6c9079f3db0767..e85cc8ed3588fe273ee1f6121b843efd5e0dc2e6 100644 (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(' ')
                        }
index d98e9a5ade6e9bbe0a3c60b03d9dd472425c35a9..618fdc0757d74334dd065f56b700fb89b92820ad 100644 (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 {