cmd/compile: fix case where func-valued field of a generic type is called

Added test example orderedmap.go (binary search tree) that requires this
fix (calling function compare in _Map).

Also added new tests slices.go and metrics.go that just work.

Change-Id: Ifa5f42ab6eee9aa54c40f0eca19e00a87f8f608a
Reviewed-on: https://go-review.googlesource.com/c/go/+/301829
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Dan Scales 2021-03-14 13:46:23 -07:00
parent c236095638
commit 96aecdcb36
4 changed files with 807 additions and 0 deletions

View file

@ -389,6 +389,13 @@ func (subst *subster) node(n ir.Node) ir.Node {
typecheck.Callee(call.X)
call.SetTypecheck(0)
typecheck.Call(call)
} else if call.X.Op() == ir.ODOT || call.X.Op() == ir.ODOTPTR {
// An OXDOT for a generic receiver was resolved to
// an access to a field which has a function
// value. Typecheck the call to that function, now
// that the OXDOT was resolved.
call.SetTypecheck(0)
typecheck.Call(call)
} else if call.X.Op() != ir.OFUNCINST {
// A call with an OFUNCINST will get typechecked
// in stencil() once we have created & attached the