[dev.typeparams] cmd/compile: do transformCall with non-shape type of call

Do the transformCall using the original types2-derived type of the call
(in particular, the types of the params as non-shapes). Currently, since
we were using the param types of the instantiation, we might add in
interface conversions to an interface with shapes in the one case of a
full-instantiated generic call. So, we do the transformCall() before
installing the shaped-based instantiation. transformCall() works
correctly even in the case of OCALL/FUNCINST.

Fixed two related bugs:
  - Fixed case where we still were not correctly substituting the types
    for a function instantiation.
  - The type substituter needs to copy field flags while substituting in
    tstruct.

Change-Id: I14e960737d6840a75846ede480e6650534ba3af3
Reviewed-on: https://go-review.googlesource.com/c/go/+/340259
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Dan Scales 2021-08-05 15:59:39 -07:00
parent ac78501b9c
commit 5e33d11e10
4 changed files with 22 additions and 6 deletions

View file

@ -119,6 +119,14 @@ func (g *irgen) stencil() {
fmt.Printf("%s in %v at generic function call: %v - %v\n", dictkind, decl, inst.X, call)
}
}
// Transform the Call now, which changes OCALL to
// OCALLFUNC and does typecheckaste/assignconvfn. Do
// it before installing the instantiation, so we are
// checking against non-shape param types in
// typecheckaste.
transformCall(call)
// Replace the OFUNCINST with a direct reference to the
// new stenciled function
call.X = st.Nname
@ -132,9 +140,6 @@ func (g *irgen) stencil() {
// Add dictionary to argument list.
call.Args.Prepend(dictValue)
// Transform the Call now, which changes OCALL
// to OCALLFUNC and does typecheckaste/assignconvfn.
transformCall(call)
modified = true
}
if n.Op() == ir.OCALLMETH && n.(*ir.CallExpr).X.Op() == ir.ODOTMETH && len(deref(n.(*ir.CallExpr).X.Type().Recv().Type).RParams()) > 0 {