mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: fix delayTransform condition
The delayTransform only checks whether ir.CurFunc is generic function or not. but when compiling a non-generic closure inside a generic function, we also want to delay the transformation, which delayTransform fails to detect, since when ir.CurFunc is the closure, not the top level function. Instead, we must rely on irgen.topFuncIsGeneric field to decide whether to delay the transformation, the same logic with what is being done for not adding closure inside a generic function to g.target.Decls list. Fixes #48609 Change-Id: I5bf5592027d112fe8b19c92eb906add424c46507 Reviewed-on: https://go-review.googlesource.com/c/go/+/351855 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Dan Scales <danscales@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
This commit is contained in:
parent
c94543b85f
commit
cfd0868fc3
5 changed files with 34 additions and 16 deletions
|
|
@ -168,7 +168,7 @@ func (g *irgen) expr0(typ types2.Type, expr syntax.Expr) ir.Node {
|
|||
if index.Op() != ir.OTYPE {
|
||||
// This is just a normal index expression
|
||||
n := Index(pos, g.typ(typ), g.expr(expr.X), index)
|
||||
if !delayTransform() {
|
||||
if !g.delayTransform() {
|
||||
// transformIndex will modify n.Type() for OINDEXMAP.
|
||||
transformIndex(n)
|
||||
}
|
||||
|
|
@ -206,7 +206,7 @@ func (g *irgen) expr0(typ types2.Type, expr syntax.Expr) ir.Node {
|
|||
|
||||
case *syntax.SliceExpr:
|
||||
n := Slice(pos, g.typ(typ), g.expr(expr.X), g.expr(expr.Index[0]), g.expr(expr.Index[1]), g.expr(expr.Index[2]))
|
||||
if !delayTransform() {
|
||||
if !g.delayTransform() {
|
||||
transformSlice(n)
|
||||
}
|
||||
return n
|
||||
|
|
@ -218,7 +218,7 @@ func (g *irgen) expr0(typ types2.Type, expr syntax.Expr) ir.Node {
|
|||
switch op := g.op(expr.Op, binOps[:]); op {
|
||||
case ir.OEQ, ir.ONE, ir.OLT, ir.OLE, ir.OGT, ir.OGE:
|
||||
n := Compare(pos, g.typ(typ), op, g.expr(expr.X), g.expr(expr.Y))
|
||||
if !delayTransform() {
|
||||
if !g.delayTransform() {
|
||||
transformCompare(n)
|
||||
}
|
||||
return n
|
||||
|
|
@ -228,7 +228,7 @@ func (g *irgen) expr0(typ types2.Type, expr syntax.Expr) ir.Node {
|
|||
return typed(x.Type(), ir.NewLogicalExpr(pos, op, x, y))
|
||||
default:
|
||||
n := Binary(pos, op, g.typ(typ), g.expr(expr.X), g.expr(expr.Y))
|
||||
if op == ir.OADD && !delayTransform() {
|
||||
if op == ir.OADD && !g.delayTransform() {
|
||||
return transformAdd(n)
|
||||
}
|
||||
return n
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue