diff --git a/go/ssa/builder.go b/go/ssa/builder.go index 8931fb46fc7..11b6423191f 100644 --- a/go/ssa/builder.go +++ b/go/ssa/builder.go @@ -829,7 +829,7 @@ func (b *builder) expr0(fn *Function, e ast.Expr, tv types.TypeAndValue) Value { // The result is a "bound". obj := sel.obj.(*types.Func) rt := fn.typ(recvType(obj)) - _, wantAddr := deptr(rt) + _, wantAddr := deref(rt) escaping := true v := b.receiver(fn, e.X, wantAddr, escaping, sel) @@ -956,9 +956,8 @@ func (b *builder) stmtList(fn *Function, list []ast.Stmt) { // // escaping is defined as per builder.addr(). func (b *builder) receiver(fn *Function, e ast.Expr, wantAddr, escaping bool, sel *selection) Value { - var v Value - if _, eptr := deptr(fn.typeOf(e)); wantAddr && !sel.indirect && !eptr { + if _, eptr := deref(fn.typeOf(e)); wantAddr && !sel.indirect && !eptr { v = b.addr(fn, e, escaping).address(fn) } else { v = b.expr(fn, e) @@ -967,7 +966,7 @@ func (b *builder) receiver(fn *Function, e ast.Expr, wantAddr, escaping bool, se last := len(sel.index) - 1 // The position of implicit selection is the position of the inducing receiver expression. v = emitImplicitSelections(fn, v, sel.index[:last], e.Pos()) - if _, vptr := deptr(v.Type()); !wantAddr && vptr { + if _, vptr := deref(v.Type()); !wantAddr && vptr { v = emitLoad(fn, v) } return v @@ -986,7 +985,7 @@ func (b *builder) setCallFunc(fn *Function, e *ast.CallExpr, c *CallCommon) { obj := sel.obj.(*types.Func) recv := recvType(obj) - _, wantAddr := deptr(recv) + _, wantAddr := deref(recv) escaping := true v := b.receiver(fn, selector.X, wantAddr, escaping, sel) if types.IsInterface(recv) { diff --git a/go/ssa/builder_generic_test.go b/go/ssa/builder_generic_test.go index c86da0cc8e8..8ddf898efd9 100644 --- a/go/ssa/builder_generic_test.go +++ b/go/ssa/builder_generic_test.go @@ -690,6 +690,26 @@ func TestInstructionString(t *testing.T) { func f13[A [3]int, PA *A](v PA) { *v = A{7} } + + //@ instrs("f14", "*ssa.Call", "invoke t1.Set(0:int)") + func f14[T any, PT interface { + Set(int) + *T + }]() { + var t T + p := PT(&t) + p.Set(0) + } + + //@ instrs("f15", "*ssa.MakeClosure", "make closure (interface{Set(int); *T}).Set$bound [t1]") + func f15[T any, PT interface { + Set(int) + *T + }]() func(int) { + var t T + p := PT(&t) + return p.Set + } ` // Parse