mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.typeparams] cmd/compile: handle calling a method on a type param in stenciling
- Have to delay the extra transformation on methods invoked on a type param, since the actual transformation (including path through embedded fields) will depend on the instantiated type. I am currently doing the transformation during the stencil substitution phase. We probably should have a separate pass after noder2 and stenciling, which drives the extra transformations that were in the old typechecker. - We handle method values (that are not called) and method calls. We don't currently handle method expressions. - Handle type substitution in function types, which is needed for function args in generic functions. - Added stringer.go and map.go tests, testing the above changes (including constraints with embedded interfaces). Change-Id: I3831a937d2b8814150f75bebf9f23ab10b93fa00 Reviewed-on: https://go-review.googlesource.com/c/go/+/290550 TryBot-Result: Go Bot <gobot@golang.org> Trust: Dan Scales <danscales@google.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Dan Scales <danscales@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
ca18c42054
commit
12e15d430d
6 changed files with 220 additions and 16 deletions
|
|
@ -119,6 +119,16 @@ func Call(pos src.XPos, typ *types.Type, fun ir.Node, args []ir.Node, dots bool)
|
|||
n := ir.NewCallExpr(pos, ir.OCALL, fun, args)
|
||||
n.IsDDD = dots
|
||||
|
||||
if fun.Op() == ir.OXDOT {
|
||||
if fun.(*ir.SelectorExpr).X.Type().Kind() != types.TTYPEPARAM {
|
||||
base.FatalfAt(pos, "Expecting type param receiver in %v", fun)
|
||||
}
|
||||
// For methods called in a generic function, don't do any extra
|
||||
// transformations. We will do those later when we create the
|
||||
// instantiated function and have the correct receiver type.
|
||||
typed(typ, n)
|
||||
return n
|
||||
}
|
||||
if fun.Op() != ir.OFUNCINST {
|
||||
// If no type params, still do normal typechecking, since we're
|
||||
// still missing some things done by tcCall below (mainly
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue