From 46b01ec667c05fb8eb8f382b173e126282acd80c Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Tue, 21 Jun 2022 07:56:25 -0700 Subject: [PATCH] [dev.unified] cmd/compile/internal/noder: remove needType logic This logic is a holdover from very early on when it wasn't as clear how we would handle dictionary entries for derived types, particularly ones that are emitted during desugaring. However, the current plan is to explicitly wire runtime type info through IR nodes, so we can drop this logic. Notably, the "needed" bit is exposed to the go/types importers, so removing it would break the x/tools importer. To minimize churn for now, we can just leave the bools in place. Change-Id: I374927887d4f3d6d711d3355607849a407d717c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/413367 Reviewed-by: David Chase Reviewed-by: Keith Randall TryBot-Result: Gopher Robot Run-TryBot: Matthew Dempsky --- src/cmd/compile/internal/noder/writer.go | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/cmd/compile/internal/noder/writer.go b/src/cmd/compile/internal/noder/writer.go index e2d2aba072..e773b8973d 100644 --- a/src/cmd/compile/internal/noder/writer.go +++ b/src/cmd/compile/internal/noder/writer.go @@ -179,7 +179,7 @@ type writerDict struct { // A derivedInfo represents a reference to an encoded generic Go type. type derivedInfo struct { idx pkgbits.Index - needed bool + needed bool // TODO(mdempsky): Remove; will break x/tools importer } // A typeInfo represents a reference to an encoded Go type. @@ -1362,13 +1362,6 @@ func (w *writer) expr(expr syntax.Expr) { targs := inst.TypeArgs if tv, ok := w.p.info.Types[expr]; ok { - // TODO(mdempsky): Be more judicious about which types are marked as "needed". - if inst.Type != nil { - w.needType(inst.Type) - } else { - w.needType(tv.Type) - } - if tv.IsType() { w.p.fatalf(expr, "unexpected type expression %v", syntax.String(expr)) } @@ -1714,20 +1707,6 @@ func (w *writer) op(op ir.Op) { w.Len(int(op)) } -func (w *writer) needType(typ types2.Type) { - // Decompose tuple into component element types. - if typ, ok := typ.(*types2.Tuple); ok { - for i := 0; i < typ.Len(); i++ { - w.needType(typ.At(i).Type()) - } - return - } - - if info := w.p.typIdx(typ, w.dict); info.derived { - w.dict.derived[info.idx].needed = true - } -} - // @@@ Package initialization // Caution: This code is still clumsy, because toolstash -cmp is -- 2.48.1