mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.typeparams] cmd/compile: allow generic funcs to call other generic funcs for stenciling
- Handle generic function calling itself or another generic function in stenciling. This is easy - after it is created, just scan an instantiated generic function for function instantiations (that may needed to be stenciled), just like non-generic functions. The types in the function instantiation will already have been set by the stenciling. - Handle OTYPE nodes in subster.node() (allows for generic type conversions). - Eliminated some duplicated work in subster.typ(). - Added new test case fact.go that tests a generic function calling itself, and simple generic type conversions. - Cause an error if a generic function is to be exported (which we don't handle yet). - Fixed some suggested changes in the add.go test case that I missed in the last review. Change-Id: I5d61704254c27962f358d5a3d2e0c62a5099f148 Reviewed-on: https://go-review.googlesource.com/c/go/+/290469 Trust: Dan Scales <danscales@google.com> Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
dcb5e0392e
commit
0fbde54ea6
4 changed files with 59 additions and 14 deletions
|
|
@ -155,6 +155,9 @@ func (g *irgen) objFinish(name *ir.Name, class ir.Class, typ *types.Type) {
|
|||
break // methods are exported with their receiver type
|
||||
}
|
||||
if types.IsExported(sym.Name) {
|
||||
if name.Class == ir.PFUNC && name.Type().NumTParams() > 0 {
|
||||
base.FatalfAt(name.Pos(), "Cannot export a generic function (yet): %v", name)
|
||||
}
|
||||
typecheck.Export(name)
|
||||
}
|
||||
if base.Flag.AsmHdr != "" && !name.Sym().Asm() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue