[dev.typeparams] cmd/compile: add CONVIFACE nodes for return values during noder2

Even if we can otherwise transform a return statement because of type
params, add CONVIFACE nodes where appropriate.

Change-Id: Ia2216d5f6805926075ba6802a4385eee1d63e37e
Reviewed-on: https://go-review.googlesource.com/c/go/+/337049
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Dan Scales 2021-07-23 14:38:04 -07:00
parent 02c0172500
commit e6d956e1c5

View file

@ -128,6 +128,11 @@ func (g *irgen) stmt(stmt syntax.Stmt) ir.Node {
if e.Type().HasTParam() {
// Delay transforming the return statement if any of the
// return values have a type param.
if !ir.HasNamedResults(ir.CurFunc) {
// But add CONVIFACE nodes where needed if
// any of the return values have interface type.
typecheckaste(ir.ORETURN, nil, false, ir.CurFunc.Type().Results(), n.Results, true)
}
n.SetTypecheck(3)
return n
}