]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile: add CONVIFACE nodes for return values during noder2
authorDan Scales <danscales@google.com>
Fri, 23 Jul 2021 21:38:04 +0000 (14:38 -0700)
committerDan Scales <danscales@google.com>
Fri, 23 Jul 2021 23:07:50 +0000 (23:07 +0000)
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>
src/cmd/compile/internal/noder/stmt.go

index b7085c4776e78faef8545394465671bca0d77d8c..5af4a2da9c634d9e40c21007e7a66697e2f89f86 100644 (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
                        }