diff options
author | Dan Scales <danscales@google.com> | 2021-03-13 22:41:51 -0800 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2021-03-15 20:28:10 +0000 |
commit | dca9c11845a950130c37f4f4e5ffb55848ff7155 (patch) | |
tree | 012cba401bfd2e79a9f9b08cf87d485dd849fd6a /test/typeparam/cons.go | |
parent | bd6aeca9686d5e672ffda1ea0cfeac7a3e7a20a4 (diff) | |
download | go-dca9c11845a950130c37f4f4e5ffb55848ff7155.tar.gz go-dca9c11845a950130c37f4f4e5ffb55848ff7155.zip |
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>
Diffstat (limited to 'test/typeparam/cons.go')
-rw-r--r-- | test/typeparam/cons.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/test/typeparam/cons.go b/test/typeparam/cons.go index 08a825f59f..8d255ebdb8 100644 --- a/test/typeparam/cons.go +++ b/test/typeparam/cons.go @@ -88,9 +88,8 @@ func _Map[a, b any](f _Function[a, b], xs _List[a]) _List[b] { func main() { var xs _List[int] = _Cons[int]{3, _Cons[int]{6, _Nil[int]{}}} - // TODO(danscales): Remove conversion calls in next two, needed for now. - var ys _List[int] = _Map[int, int](_Function[int, int](incr{-5}), xs) - var xz _List[bool] = _Map[int, bool](_Function[int, bool](pos{}), ys) + var ys _List[int] = _Map[int, int](incr{-5}, xs) + var xz _List[bool] = _Map[int, bool](pos{}, ys) cs1 := xz.(_Cons[bool]) cs2 := cs1.Tail.(_Cons[bool]) _, ok := cs2.Tail.(_Nil[bool]) |