1
0
mirror of https://github.com/golang/go synced 2024-11-26 16:57:14 -07:00

cmd/compile: simplify bad conversion check

Now that we're using OCONVIDATA(x) everywhere we formerly used
OIDATA(OCONVIFACE(x)), there should be no OCONVIFACE operations that
take a shape type.

Change-Id: I4fb056456c60481c6dfe7bc111fca6223567e6a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/344577
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
This commit is contained in:
Keith Randall 2021-08-24 14:30:24 -07:00
parent c2f96e686f
commit 5d863f89fe

View File

@ -732,22 +732,16 @@ func (g *irgen) genericSubst(newsym *types.Sym, nameNode *ir.Name, shapes []*typ
g.instTypeList = append(g.instTypeList, subst.ts.InstTypeList...) g.instTypeList = append(g.instTypeList, subst.ts.InstTypeList...)
if doubleCheck { if doubleCheck {
okConvs := map[ir.Node]bool{}
ir.Visit(newf, func(n ir.Node) { ir.Visit(newf, func(n ir.Node) {
if n.Op() == ir.OIDATA { if n.Op() != ir.OCONVIFACE {
// IDATA(OCONVIFACE(x)) is ok, as we don't use the type of x. return
// TODO: use some other op besides OCONVIFACE. ONEW might work
// (with appropriate direct vs. indirect interface cases).
okConvs[n.(*ir.UnaryExpr).X] = true
} }
if n.Op() == ir.OCONVIFACE && !okConvs[n] {
c := n.(*ir.ConvExpr) c := n.(*ir.ConvExpr)
if c.X.Type().HasShape() { if c.X.Type().HasShape() {
ir.Dump("BAD FUNCTION", newf) ir.Dump("BAD FUNCTION", newf)
ir.Dump("BAD CONVERSION", c) ir.Dump("BAD CONVERSION", c)
base.Fatalf("converting shape type to interface") base.Fatalf("converting shape type to interface")
} }
}
}) })
} }