From 0d1e293b2329a013f03ea3f742f1716098ee282c Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Fri, 14 May 2021 10:05:16 -0700 Subject: [PATCH] [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 Run-TryBot: Robert Griesemer TryBot-Result: Go Bot Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/types_test.go | 3 +++ src/cmd/compile/internal/types2/typestring.go | 2 +- src/cmd/compile/internal/types2/typestring_test.go | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/types2/types_test.go b/src/cmd/compile/internal/types2/types_test.go index 11dca0b53d..1525844f2d 100644 --- a/src/cmd/compile/internal/types2/types_test.go +++ b/src/cmd/compile/internal/types2/types_test.go @@ -7,3 +7,6 @@ package types2 func init() { acceptMethodTypeParams = true } + +// Debug is set if types2 is built with debug mode enabled. +const Debug = debug diff --git a/src/cmd/compile/internal/types2/typestring.go b/src/cmd/compile/internal/types2/typestring.go index 40016697b7..e85cc8ed35 100644 --- a/src/cmd/compile/internal/types2/typestring.go +++ b/src/cmd/compile/internal/types2/typestring.go @@ -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(' ') } diff --git a/src/cmd/compile/internal/types2/typestring_test.go b/src/cmd/compile/internal/types2/typestring_test.go index d98e9a5ade..618fdc0757 100644 --- a/src/cmd/compile/internal/types2/typestring_test.go +++ b/src/cmd/compile/internal/types2/typestring_test.go @@ -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 { -- 2.50.0