aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/types.go
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-01-30 08:43:58 -0800
committerDan Scales <danscales@google.com>2021-02-01 22:05:52 +0000
commit13a741298377d30fc2b3fc51fa9aa52eed6d56e4 (patch)
tree15fdb1b080662df49d9b67d5bf884cbe871ee465 /src/cmd/compile/internal/noder/types.go
parent0aafd6912422570625414da6e5ed5ba2c371fcec (diff)
downloadgo-13a741298377d30fc2b3fc51fa9aa52eed6d56e4.tar.gz
go-13a741298377d30fc2b3fc51fa9aa52eed6d56e4.zip
[dev.typeparams] Parse a generic type arg for generic function call
Will now run "go tool compile -G=2 -W=2" on a simple generic function with one type parameter and a call to that function with one explicit type argument. Next change will handle multiple type arguments. Change-Id: Ia7d17ea2a02bf99bd50e673ac80ae4aad4c48440 Reviewed-on: https://go-review.googlesource.com/c/go/+/288432 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/cmd/compile/internal/noder/types.go')
-rw-r--r--src/cmd/compile/internal/noder/types.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/noder/types.go b/src/cmd/compile/internal/noder/types.go
index b4ad9cfc5b8..1e719698582 100644
--- a/src/cmd/compile/internal/noder/types.go
+++ b/src/cmd/compile/internal/noder/types.go
@@ -39,7 +39,7 @@ func (g *irgen) typ(typ types2.Type) *types.Type {
// Ensure we calculate the size for all concrete types seen by
// the frontend. This is another heavy hammer for something that
// should really be the backend's responsibility instead.
- if !res.IsUntyped() {
+ if res != nil && !res.IsUntyped() && !res.IsFuncArgStruct() {
types.CheckSize(res)
}
}
@@ -106,6 +106,22 @@ func (g *irgen) typ0(typ types2.Type) *types.Type {
tp.SetSym(g.sym(typ.Obj()))
return tp
+ case *types2.Tuple:
+ // Tuples are used for the type of a function call (i.e. the
+ // return value of the function).
+ if typ == nil {
+ return (*types.Type)(nil)
+ }
+ fields := make([]*types.Field, typ.Len())
+ for i := range fields {
+ fields[i] = g.param(typ.At(i))
+ }
+ t := types.NewStruct(types.LocalPkg, fields)
+ types.CheckSize(t)
+ // Can only set after doing the types.CheckSize()
+ t.StructType().Funarg = types.FunargResults
+ return t
+
default:
base.FatalfAt(src.NoXPos, "unhandled type: %v (%T)", typ, typ)
panic("unreachable")