summaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ir/expr.go
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-07-19 12:41:30 -0700
committerDan Scales <danscales@google.com>2021-07-22 04:45:49 +0000
commit8e9109e95a8c4be92ba018a1353104706acf8466 (patch)
tree02c74b9d2986860bb1fbe2921dec64023cee74ee /src/cmd/compile/internal/ir/expr.go
parentee20dff27debb738ca3a89a7a30113771c1c078f (diff)
downloadgo-git-8e9109e95a8c4be92ba018a1353104706acf8466.tar.gz
[dev.typeparams] Fix problem with 14.go
Removed a case in transformCall() where we were setting a type on n, which isn't needed, since noder2 already set the type of n. More importantly, we are losing information, since the type of the results may be a shape type, but the actual type of call is the known type from types2, which may be a concrete type (in this case Zero[MyInt]). That concrete type will then be used correctly if the concrete result is converted to an interface. If we are inlining the call to Zero[MyInt], we need to add an implicit CONVNOP operation, since we are going to use the result variable directly, which has a shape type. So, add an implicit CONVNOP to remember that the known type is the concrete type. Also cleaned up 14.go a bit, so it is more understandable. Renamed type T to AnyInt, since T is used elsewhere as a type parameter. Reformatted Zero function and added a comment. Change-Id: Id917a2e054e0bbae9bd302232853fa8741d49b64 Reviewed-on: https://go-review.googlesource.com/c/go/+/336430 Trust: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ir/expr.go')
-rw-r--r--src/cmd/compile/internal/ir/expr.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ir/expr.go b/src/cmd/compile/internal/ir/expr.go
index 9c800dcd1a..09d6d87f06 100644
--- a/src/cmd/compile/internal/ir/expr.go
+++ b/src/cmd/compile/internal/ir/expr.go
@@ -349,6 +349,14 @@ func (n *InlinedCallExpr) SingleResult() Node {
if have := len(n.ReturnVars); have != 1 {
base.FatalfAt(n.Pos(), "inlined call has %v results, expected 1", have)
}
+ if !n.Type().HasShape() && n.ReturnVars[0].Type().HasShape() {
+ // If the type of the call is not a shape, but the type of the return value
+ // is a shape, we need to do an implicit conversion, so the real type
+ // of n is maintained.
+ r := NewConvExpr(n.Pos(), OCONVNOP, n.Type(), n.ReturnVars[0])
+ r.SetTypecheck(1)
+ return r
+ }
return n.ReturnVars[0]
}