]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: add support for generic channels and type conversion during calls
authorDan Scales <danscales@google.com>
Sun, 14 Mar 2021 06:41:51 +0000 (22:41 -0800)
committerDan Scales <danscales@google.com>
Mon, 15 Mar 2021 20:28:10 +0000 (20:28 +0000)
commitdca9c11845a950130c37f4f4e5ffb55848ff7155
tree012cba401bfd2e79a9f9b08cf87d485dd849fd6a
parentbd6aeca9686d5e672ffda1ea0cfeac7a3e7a20a4
cmd/compile:  add support for generic channels and type conversion during calls

Add support for channels in subster.typ(). Add new test file chans.go.

To support assignability of bidirectional channel args to directional
channel params, I needed to type check generic calls after they are
instantiated. (Eventually, we will create separate functions to just do
the assignability logic, so we don't need to call the old typechecker in
this case.) So, for generic calls, we now leave the call as OCALL (as a
signal that the call still needs typechecking), and do typecheck.Call()
during stenciling.

Smaller changes:
 - Set the type of an instantiated OCLOSURE node (and not just the associated
   OFUNC node)

 - In instTypeName2, filter out the space that types2.TypeString inserts
   after a common in a typelist. Our standard naming requires no space
   after the comma.

 - With the assignability fix above, I no longer need the explicit
   conversions in cons.go.

Change-Id: I148858bfc6708c0aa3f50bad7debce2b8c8c091f
Reviewed-on: https://go-review.googlesource.com/c/go/+/301669
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/noder/helpers.go
src/cmd/compile/internal/noder/stencil.go
src/cmd/compile/internal/noder/types.go
test/typeparam/chans.go [new file with mode: 0644]
test/typeparam/cons.go