[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 <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Matthew Dempsky 2022-06-21 07:56:25 -07:00
parent a3e474f867
commit 46b01ec667

View File

@ -179,7 +179,7 @@ type writerDict struct {
// A derivedInfo represents a reference to an encoded generic Go type. // A derivedInfo represents a reference to an encoded generic Go type.
type derivedInfo struct { type derivedInfo struct {
idx pkgbits.Index 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. // A typeInfo represents a reference to an encoded Go type.
@ -1362,13 +1362,6 @@ func (w *writer) expr(expr syntax.Expr) {
targs := inst.TypeArgs targs := inst.TypeArgs
if tv, ok := w.p.info.Types[expr]; ok { 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() { if tv.IsType() {
w.p.fatalf(expr, "unexpected type expression %v", syntax.String(expr)) 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)) 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 // @@@ Package initialization
// Caution: This code is still clumsy, because toolstash -cmp is // Caution: This code is still clumsy, because toolstash -cmp is