If we have all channel types in a constraint, there is no structural type if they don't all have the same channel direction (and identical element types, of course). By allowing different channel types for the purposes of the structural type, as long as there is not a send-only _and_ a receive- only channel in the type set, we make it possible to find a useful, if restricted by channel direction, structural type where before there was none. So if we have unrestricted and send-only channels, the structural type is the send-only channel, and vice versa. For all operations on channels that rely on a structural type, it's always ok to have an unrestricted channel, so this is not affecting their behavior. But it makes those operations more flexible in the presence of type parameters containing mixed channel types. For constraint type inference, where we currently may not infer a channel at all, this change allows us to infer a more restricted channel (send- or receive-only). If the inferred channel type is a valid type argument we win; if not we haven't lost anything. Use structuralType for send and receive operations and adjust related error messages (the error message that change are the ones involving type parameters, so historic error messages are preserved). Fixes #45920. Change-Id: If3a64d29c37e7734d3163df330f8b02dd032bc60 Reviewed-on: https://go-review.googlesource.com/c/go/+/363075 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> |
||
|---|---|---|
| .github | ||
| api | ||
| doc | ||
| lib/time | ||
| misc | ||
| src | ||
| test | ||
| .gitattributes | ||
| .gitignore | ||
| AUTHORS | ||
| CONTRIBUTING.md | ||
| CONTRIBUTORS | ||
| LICENSE | ||
| PATENTS | ||
| README.md | ||
| SECURITY.md | ||
| codereview.cfg | ||
README.md
The Go Programming Language
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Download and Install
Binary Distributions
Official binary distributions are available at https://golang.org/dl/.
After downloading a binary release, visit https://golang.org/doc/install for installation instructions.
Install From Source
If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source for source installation instructions.
Contributing
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines at https://golang.org/doc/contribute.
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.